Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-06-07 01:54:02
Exec Total Coverage
Lines: 8639 13295 65.0%
Functions: 329 429 76.7%
Branches: 6832 14576 46.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include <string.h>
12 #include <stdio.h>
13 #include "base/zc_alleg.h"
14 #include "zc/guys.h"
15 #include "zc/zelda.h"
16 #include "base/zsys.h"
17
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 #include "zc/maps.h"
18 #include "zc/hero.h"
19 #include "subscr.h"
20 #include "zc/ffscript.h"
21 #include "gamedata.h"
22 #include "defdata.h"
23 #include "zscriptversion.h"
24 #include "particles.h"
25 #include "base/zc_math.h"
26 #include "slopes.h"
27 extern particle_list particles;
28
29 extern FFScript FFCore;
30 extern word item_doscript[256];
31 extern refInfo itemScriptData[256];
32 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
33 extern ZModule zcm;
34 extern HeroClass Hero;
35 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
36 extern zinitdata zinit;
37
38 int32_t repaircharge=0;
39 bool adjustmagic=false;
40 bool learnslash=false;
41 int32_t wallm_load_clk=0;
42 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
43 int32_t vhead=0;
44 int32_t guycarryingitem=0;
45
46 char *guy_string[eMAXGUYS];
47
48 void never_return(int32_t index);
49 void playLevelMusic();
50
51 // If an enemy is this far out of the playing field, just remove it.
52 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
53 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
54 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
55 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
56
57 608339 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
58 {
59 608339 int32_t c = coord.getInt();
60
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 608072 times.
608339 if(nearest_half)
61 {
62
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 608072 times.
608072 if (c < 0)
63 c -= val / 2;
64 608072 else c += (val/2);
65 608072 }
66 608339 c -= c % val;
67 608339 coord = c;
68 608339 }
69
70 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
71 {
72 return
73 (
74 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
75 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
76 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
77 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
78 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
79 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
80 );
81 }
82
83 namespace
84 {
85 int32_t trapConstantHorizontalID;
86 int32_t trapConstantVerticalID;
87 int32_t trapLOSHorizontalID;
88 int32_t trapLOSVerticalID;
89 int32_t trapLOS4WayID;
90
91 int32_t cornerTrapID;
92 int32_t centerTrapID;
93
94 int32_t rockID;
95 int32_t zoraID;
96 int32_t statueID;
97 }
98
99 102 void identifyCFEnemies()
100 {
101 102 trapConstantHorizontalID=-1;
102 102 trapConstantVerticalID=-1;
103 102 trapLOSHorizontalID=-1;
104 102 trapLOSVerticalID=-1;
105 102 trapLOS4WayID=-1;
106 102 cornerTrapID=-1;
107 102 centerTrapID=-1;
108 102 rockID=-1;
109 102 zoraID=-1;
110 102 statueID=-1;
111
112
2/2
✓ Branch 0 taken 52224 times.
✓ Branch 1 taken 102 times.
52326 for(int32_t i=0; i<eMAXGUYS; i++)
113 {
114
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 52123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
52224 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
115 101 trapLOSHorizontalID=i;
116
4/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 52119 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
117 102 trapLOSVerticalID=i;
118
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
119 102 trapLOS4WayID=i;
120
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
121 102 trapConstantHorizontalID=i;
122
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
123 102 trapConstantVerticalID=i;
124
125
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
126 102 cornerTrapID=i;
127
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
128 102 centerTrapID=i;
129
130
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 52122 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
131 102 rockID=i;
132
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 52117 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
133 102 zoraID=i;
134
135
4/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 52116 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 102 times.
52224 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
136 102 statueID=i;
137 52224 }
138 102 }
139
140 25 int32_t random_layer_enemy()
141 {
142 25 int32_t cnt=count_layer_enemies();
143
144
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
145 {
146 return eNONE;
147 }
148
149 25 int32_t ret=zc_oldrand()%cnt;
150 25 cnt=0;
151
152
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
153 {
154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
155 {
156 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
157
158
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
159 {
160
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
161 {
162
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
163 {
164 25 return layerscreen->enemy[j];
165 }
166
167 102 ++cnt;
168 102 }
169 102 }
170 }
171 }
172
173 return eNONE;
174 25 }
175
176 39 int32_t count_layer_enemies()
177 {
178 39 int32_t cnt=0;
179
180
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
181 {
182
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
183 {
184 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
185
186
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
187 {
188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
189 {
190 390 ++cnt;
191 390 }
192 390 }
193 39 }
194 234 }
195
196 39 return cnt;
197 }
198
199 134837 int32_t hero_on_wall()
200 {
201 134837 zfix lx = Hero.getX();
202 134837 zfix ly = Hero.getY();
203
204
205 //zprint2("hero_on_wall x is: %d\n", lx);
206 //zprint2("hero_on_wall y is: %d\n", ly);
207
208
4/4
✓ Branch 0 taken 125829 times.
✓ Branch 1 taken 9008 times.
✓ Branch 2 taken 4059 times.
✓ Branch 3 taken 121770 times.
134837 if(lx>=48 && lx<=192)
209 {
210
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 121624 times.
121770 if(ly==32) return up+1;
211
212
2/2
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 121494 times.
121624 if(ly==128) return down+1;
213 121494 }
214
215
4/4
✓ Branch 0 taken 125366 times.
✓ Branch 1 taken 9195 times.
✓ Branch 2 taken 10454 times.
✓ Branch 3 taken 114912 times.
134561 if(ly>=48 && ly<=112)
216 {
217
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 114784 times.
114912 if(lx==32) return left+1;
218
219
2/2
✓ Branch 0 taken 114724 times.
✓ Branch 1 taken 60 times.
114784 if(lx==208) return right+1;
220 114724 }
221
222 134373 return 0;
223 134837 }
224
225 681853 bool tooclose(int32_t x,int32_t y,int32_t d)
226 {
227
2/2
✓ Branch 0 taken 504986 times.
✓ Branch 1 taken 176867 times.
681853 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
228 }
229
230 1894781 bool enemy::overpit(enemy *e)
231 {
232 // This function (and shadow_overpit) has been broken since it was written, and only
233 // checked the same diagonal of the hitbox, over and over again. The bug is because both
234 // loops used the same variable name.
235 // Checking literally every pixel seems like overkill, so for now let's continue to
236 // do the single diagonal but just once. That's why the outer loop is commented out.
237
238 // for ( int32_t q = 0; q < hxsz; ++q )
239 {
240
2/2
✓ Branch 0 taken 17626720 times.
✓ Branch 1 taken 1891613 times.
19518333 for ( int32_t q = 0; q < hysz; ++q )
241 {
242 //check every pixel of the hitbox
243
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 17623552 times.
17626720 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
244 {
245 //if the hitbox is over a pit, we can't land
246 3168 return true;
247 }
248 17623552 }
249 }
250 1891613 return false;
251 1894781 }
252
253 3423082 bool enemy::shadow_overpit(enemy *e)
254 {
255 // for ( int32_t q = 0; q < hxsz; ++q )
256 {
257
2/2
✓ Branch 0 taken 49936097 times.
✓ Branch 1 taken 3419230 times.
53355327 for ( int32_t q = 0; q < hysz; ++q )
258 {
259 //check every pixel of the hitbox
260
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 49932245 times.
49936097 if ( ispitfall(x+q+hxofs, y+q+hyofs+hysz-2) )
261 {
262 //if the hitbox is over a pit, we can't land
263 3852 return true;
264 }
265 49932245 }
266 }
267 3419230 return false;
268 3423082 }
269
270 // Returns true iff a combo type or flag precludes enemy movement.
271 3655860 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
272 {
273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3655860 times.
3655860 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
274 3655860 int32_t c = COMBOTYPE(dx,dy);
275
4/4
✓ Branch 0 taken 2393092 times.
✓ Branch 1 taken 1262768 times.
✓ Branch 2 taken 603955 times.
✓ Branch 3 taken 658813 times.
4918628 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
276
3/6
✓ Branch 0 taken 1248968 times.
✓ Branch 1 taken 2406892 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1248968 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3655860 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_bit(quest_rules,qr_DROWN));
277
4/6
✓ Branch 0 taken 1284387 times.
✓ Branch 1 taken 2371473 times.
✓ Branch 2 taken 1284387 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1284387 times.
✗ Branch 5 not taken.
7312235 return c==cPIT || c==cPITB || c==cPITC ||
278
4/6
✓ Branch 0 taken 1284387 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1284387 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1187342 times.
✓ Branch 5 taken 97045 times.
1284387 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
279 // Block enemies type and block enemies flags
280
2/2
✓ Branch 0 taken 1283039 times.
✓ Branch 1 taken 1185994 times.
97045 combo_class_buf[c].block_enemies&1 ||
281
3/4
✓ Branch 0 taken 1283037 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1283037 times.
✗ Branch 3 not taken.
1283039 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
282
4/4
✓ Branch 0 taken 1282818 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 1282808 times.
✓ Branch 3 taken 10 times.
1283037 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
283 // Check for ladder-only combos which aren't dried water
284
4/4
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 1282167 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 5 times.
2565611 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
285 // Check for drownable water
286
4/4
✓ Branch 0 taken 116125 times.
✓ Branch 1 taken 1166678 times.
✓ Branch 2 taken 10688 times.
✓ Branch 3 taken 105437 times.
1282803 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
287 1284902 }
288
289 // Returns true iff enemy is floating and blocked by a combo type or flag.
290 4239589 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
291 {
292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4239589 times.
4239589 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
293
4/4
✓ Branch 0 taken 2791752 times.
✓ Branch 1 taken 1447837 times.
✓ Branch 2 taken 1220488 times.
✓ Branch 3 taken 227349 times.
5687426 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
294
3/4
✓ Branch 0 taken 2801756 times.
✓ Branch 1 taken 1437833 times.
✓ Branch 2 taken 1437833 times.
✗ Branch 3 not taken.
5677422 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
295
2/2
✓ Branch 0 taken 525666 times.
✓ Branch 1 taken 3713923 times.
7953512 return ((special==spw_floater)&&
296
2/2
✓ Branch 0 taken 3707812 times.
✓ Branch 1 taken 6111 times.
3713923 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
297
1/2
✓ Branch 0 taken 3707812 times.
✗ Branch 1 not taken.
3707812 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
298
2/2
✓ Branch 0 taken 3707801 times.
✓ Branch 1 taken 11 times.
3707812 (MAPFLAG(dx,dy)==mfNOENEMY)||
299
1/2
✓ Branch 0 taken 3707801 times.
✗ Branch 1 not taken.
3707801 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
300
4/4
✓ Branch 0 taken 971536 times.
✓ Branch 1 taken 2736265 times.
✓ Branch 2 taken 1984 times.
✓ Branch 3 taken 969552 times.
7413618 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
301
2/2
✓ Branch 0 taken 2729802 times.
✓ Branch 1 taken 976015 times.
3705817 (pit_blocks && ispitfall(dx,dy))));
302 4239589 }
303 // Returns true iff a combo type or flag precludes enemy movement.
304 241498 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
305 {
306 241498 int32_t c = COMBOTYPE(dx,dy);
307 241498 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
308
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 214173 times.
241498 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_bit(quest_rules,qr_DROWN);
309
3/6
✓ Branch 0 taken 241498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241498 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241498 times.
✗ Branch 5 not taken.
917746 return c==cPIT || c==cPITB || c==cPITC ||
310
4/6
✓ Branch 0 taken 241498 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241498 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 217463 times.
✓ Branch 5 taken 24035 times.
241498 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
311 // Block enemies type and block enemies flags
312
2/2
✓ Branch 0 taken 241410 times.
✓ Branch 1 taken 217375 times.
24035 combo_class_buf[c].block_enemies&1 ||
313
3/4
✓ Branch 0 taken 241274 times.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 241274 times.
✗ Branch 3 not taken.
241410 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
314
4/4
✓ Branch 0 taken 237801 times.
✓ Branch 1 taken 3473 times.
✓ Branch 2 taken 237545 times.
✓ Branch 3 taken 256 times.
241274 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
315 // Check for ladder-only combos which aren't dried water
316
3/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 237511 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
475090 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
317 // Check for drownable water
318
4/4
✓ Branch 0 taken 35833 times.
✓ Branch 1 taken 201712 times.
✓ Branch 2 taken 27451 times.
✓ Branch 3 taken 8382 times.
237545 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
319 }
320
321 // Returns true iff enemy is floating and blocked by a combo type or flag.
322 114598 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
323 {
324
2/2
✓ Branch 0 taken 112991 times.
✓ Branch 1 taken 1607 times.
114598 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
325 114598 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114598 times.
229196 return ((special==spw_floater)&&
327
1/2
✓ Branch 0 taken 114598 times.
✗ Branch 1 not taken.
114598 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
328
1/2
✓ Branch 0 taken 114598 times.
✗ Branch 1 not taken.
114598 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
329
1/2
✓ Branch 0 taken 114598 times.
✗ Branch 1 not taken.
114598 (MAPFLAG(dx,dy)==mfNOENEMY)||
330
1/2
✓ Branch 0 taken 114598 times.
✗ Branch 1 not taken.
114598 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
331
4/4
✓ Branch 0 taken 1607 times.
✓ Branch 1 taken 112991 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 1389 times.
228978 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
332
2/2
✓ Branch 0 taken 112991 times.
✓ Branch 1 taken 1389 times.
114380 (pit_blocks && ispitfall(dx,dy))));
333 }
334
335 /**********************************/
336 /******* Enemy Base Class *******/
337 /**********************************/
338
339 /* ROM data flags
340
341 */
342
343 eFire::eFire(eFire const & other, bool new_script_uid, bool clear_parent_script_UID):
344 //Struct Element Type Purpose
345 //sprite(other),
346 enemy(other),
347 clk4(other.clk4),
348 shield(other.shield)
349
350 {
351
352 //arrays
353
354 if(other.scrmem)
355 {
356 alloc_scriptmem();
357 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
358
359 scrmem->scriptData = other.scrmem->scriptData;
360 }
361 else scrmem = NULL;
362 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
363 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
364
365 for(int32_t i=0; i<edefLAST255; i++)
366 defense[i]=other.defense[i];
367 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
368 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
369
370 if(new_script_uid)
371 {
372 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
373 }
374 if(clear_parent_script_UID)
375 {
376 parent_script_UID = 0;
377 }
378 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
379 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
380
381 for ( int32_t q = 0; q < 8; q++ )
382 {
383 initD[q] = other.initD[q];
384 weap_initiald[q] = other.weap_initiald[q];
385 }
386 for ( int32_t q = 0; q < 2; q++ )
387 {
388 initA[q] = other.initA[q];
389 weap_initiala[q] = other.weap_initiala[q];
390 }
391 }
392
393 eOther::eOther(eOther const & other, bool new_script_uid, bool clear_parent_script_UID):
394 //Struct Element Type Purpose
395 //sprite(other),
396 enemy(other),
397 clk4(other.clk4),
398 shield(other.shield)
399
400 {
401
402 //arrays
403
404 if(other.scrmem)
405 {
406 alloc_scriptmem();
407 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
408
409 scrmem->scriptData = other.scrmem->scriptData;
410 }
411 else scrmem = NULL;
412 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
413 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
414
415 for(int32_t i=0; i<edefLAST255; i++)
416 defense[i]=other.defense[i];
417 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
418 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
419
420 if(new_script_uid)
421 {
422 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
423 }
424 if(clear_parent_script_UID)
425 {
426 parent_script_UID = 0;
427 }
428 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
429 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
430
431 for ( int32_t q = 0; q < 8; q++ )
432 {
433 initD[q] = other.initD[q];
434 weap_initiald[q] = other.weap_initiald[q];
435 }
436 for ( int32_t q = 0; q < 2; q++ )
437 {
438 initA[q] = other.initA[q];
439 weap_initiala[q] = other.weap_initiala[q];
440 }
441 }
442
443
444
445
446 eScript::eScript(eScript const & other, bool new_script_uid, bool clear_parent_script_UID):
447 //Struct Element Type Purpose
448 //sprite(other),
449 enemy(other),
450 clk4(other.clk4),
451 shield(other.shield)
452
453 {
454
455 //arrays
456
457 if(other.scrmem)
458 {
459 alloc_scriptmem();
460 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
461
462 scrmem->scriptData = other.scrmem->scriptData;
463 }
464 else scrmem = NULL;
465 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
466 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
467
468 for(int32_t i=0; i<edefLAST255; i++)
469 defense[i]=other.defense[i];
470 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
471 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
472
473 if(new_script_uid)
474 {
475 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
476 }
477 if(clear_parent_script_UID)
478 {
479 parent_script_UID = 0;
480 }
481 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
482 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
483
484 for ( int32_t q = 0; q < 8; q++ )
485 {
486 initD[q] = other.initD[q];
487 weap_initiald[q] = other.weap_initiald[q];
488 }
489 for ( int32_t q = 0; q < 2; q++ )
490 {
491 initA[q] = other.initA[q];
492 weap_initiala[q] = other.weap_initiala[q];
493 }
494 }
495
496 eFriendly::eFriendly(eFriendly const & other, bool new_script_uid, bool clear_parent_script_UID):
497 //Struct Element Type Purpose
498 //sprite(other),
499 enemy(other),
500 clk4(other.clk4),
501 shield(other.shield)
502
503 {
504
505 //arrays
506
507 if(other.scrmem)
508 {
509 alloc_scriptmem();
510 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
511
512 scrmem->scriptData = other.scrmem->scriptData;
513 }
514 else scrmem = NULL;
515 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
516 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
517
518 for(int32_t i=0; i<edefLAST255; i++)
519 defense[i]=other.defense[i];
520 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
521 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
522
523 if(new_script_uid)
524 {
525 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
526 }
527 if(clear_parent_script_UID)
528 {
529 parent_script_UID = 0;
530 }
531 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
532 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
533
534 for ( int32_t q = 0; q < 8; q++ )
535 {
536 initD[q] = other.initD[q];
537 weap_initiald[q] = other.weap_initiald[q];
538 }
539 for ( int32_t q = 0; q < 2; q++ )
540 {
541 initA[q] = other.initA[q];
542 weap_initiala[q] = other.weap_initiala[q];
543 }
544 }
545
546 eGhini::eGhini(eGhini const & other, bool new_script_uid, bool clear_parent_script_UID):
547 //Struct Element Type Purpose
548 //sprite(other),
549 enemy(other),
550 clk4(other.clk4),
551 ox(other.ox),
552 oy(other.oy),
553 c(other.c)
554
555 {
556
557 //arrays
558
559 if(other.scrmem)
560 {
561 alloc_scriptmem();
562 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
563
564 scrmem->scriptData = other.scrmem->scriptData;
565 }
566 else scrmem = NULL;
567 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
568 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
569
570 for(int32_t i=0; i<edefLAST255; i++)
571 defense[i]=other.defense[i];
572 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
573 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
574
575 if(new_script_uid)
576 {
577 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
578 }
579 if(clear_parent_script_UID)
580 {
581 parent_script_UID = 0;
582 }
583 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
584 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
585
586 for ( int32_t q = 0; q < 8; q++ )
587 {
588 initD[q] = other.initD[q];
589 weap_initiald[q] = other.weap_initiald[q];
590 }
591 for ( int32_t q = 0; q < 2; q++ )
592 {
593 initA[q] = other.initA[q];
594 weap_initiala[q] = other.weap_initiala[q];
595 }
596 }
597
598 eTektite::eTektite(eTektite const & other, bool new_script_uid, bool clear_parent_script_UID):
599 //Struct Element Type Purpose
600 //sprite(other),
601 enemy(other),
602 old_y(other.old_y),
603 clk2start(other.clk2start),
604 cstart(other.cstart),
605 c(other.c)
606
607 {
608
609 //arrays
610
611 if(other.scrmem)
612 {
613 alloc_scriptmem();
614 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
615
616 scrmem->scriptData = other.scrmem->scriptData;
617 }
618 else scrmem = NULL;
619 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
620 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
621
622 for(int32_t i=0; i<edefLAST255; i++)
623 defense[i]=other.defense[i];
624 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
625 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
626
627 if(new_script_uid)
628 {
629 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
630 }
631 if(clear_parent_script_UID)
632 {
633 parent_script_UID = 0;
634 }
635 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
636 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
637
638 for ( int32_t q = 0; q < 8; q++ )
639 {
640 initD[q] = other.initD[q];
641 weap_initiald[q] = other.weap_initiald[q];
642 }
643 for ( int32_t q = 0; q < 2; q++ )
644 {
645 initA[q] = other.initA[q];
646 weap_initiala[q] = other.weap_initiala[q];
647 }
648 }
649
650 eItemFairy::eItemFairy(eItemFairy const & other, bool new_script_uid, bool clear_parent_script_UID):
651 //Struct Element Type Purpose
652 //sprite(other),
653 enemy(other)
654 {
655
656 //arrays
657
658 if(other.scrmem)
659 {
660 alloc_scriptmem();
661 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
662
663 scrmem->scriptData = other.scrmem->scriptData;
664 }
665 else scrmem = NULL;
666 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
667 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
668
669 for(int32_t i=0; i<edefLAST255; i++)
670 defense[i]=other.defense[i];
671 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
672 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
673
674 if(new_script_uid)
675 {
676 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
677 }
678 if(clear_parent_script_UID)
679 {
680 parent_script_UID = 0;
681 }
682 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
683 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
684
685 for ( int32_t q = 0; q < 8; q++ )
686 {
687 initD[q] = other.initD[q];
688 weap_initiald[q] = other.weap_initiald[q];
689 }
690 for ( int32_t q = 0; q < 2; q++ )
691 {
692 initA[q] = other.initA[q];
693 weap_initiala[q] = other.weap_initiala[q];
694 }
695 }
696
697 ePeahat::ePeahat(ePeahat const & other, bool new_script_uid, bool clear_parent_script_UID):
698 //Struct Element Type Purpose
699 //sprite(other),
700 enemy(other),
701 ox(other.ox),
702 oy(other.oy),
703 c(other.c)
704 {
705
706 //arrays
707
708 if(other.scrmem)
709 {
710 alloc_scriptmem();
711 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
712
713 scrmem->scriptData = other.scrmem->scriptData;
714 }
715 else scrmem = NULL;
716 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
717 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
718
719 for(int32_t i=0; i<edefLAST255; i++)
720 defense[i]=other.defense[i];
721 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
722 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
723
724 if(new_script_uid)
725 {
726 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
727 }
728 if(clear_parent_script_UID)
729 {
730 parent_script_UID = 0;
731 }
732 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
733 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
734
735 for ( int32_t q = 0; q < 8; q++ )
736 {
737 initD[q] = other.initD[q];
738 weap_initiald[q] = other.weap_initiald[q];
739 }
740 for ( int32_t q = 0; q < 2; q++ )
741 {
742 initA[q] = other.initA[q];
743 weap_initiala[q] = other.weap_initiala[q];
744 }
745 }
746
747 eLeever::eLeever(eLeever const & other, bool new_script_uid, bool clear_parent_script_UID):
748 //Struct Element Type Purpose
749 //sprite(other),
750 enemy(other),
751 temprule(other.temprule)
752 {
753
754 //arrays
755
756 if(other.scrmem)
757 {
758 alloc_scriptmem();
759 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
760
761 scrmem->scriptData = other.scrmem->scriptData;
762 }
763 else scrmem = NULL;
764 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
765 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
766
767 for(int32_t i=0; i<edefLAST255; i++)
768 defense[i]=other.defense[i];
769 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
770 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
771
772 if(new_script_uid)
773 {
774 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
775 }
776 if(clear_parent_script_UID)
777 {
778 parent_script_UID = 0;
779 }
780 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
781 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
782
783 for ( int32_t q = 0; q < 8; q++ )
784 {
785 initD[q] = other.initD[q];
786 weap_initiald[q] = other.weap_initiald[q];
787 }
788 for ( int32_t q = 0; q < 2; q++ )
789 {
790 initA[q] = other.initA[q];
791 weap_initiala[q] = other.weap_initiala[q];
792 }
793 }
794
795 eWallM::eWallM(eWallM const & other, bool new_script_uid, bool clear_parent_script_UID):
796 //Struct Element Type Purpose
797 //sprite(other),
798 enemy(other)
799 {
800
801 //arrays
802
803 if(other.scrmem)
804 {
805 alloc_scriptmem();
806 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
807
808 scrmem->scriptData = other.scrmem->scriptData;
809 }
810 else scrmem = NULL;
811 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
812 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
813
814 for(int32_t i=0; i<edefLAST255; i++)
815 defense[i]=other.defense[i];
816 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
817 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
818
819 if(new_script_uid)
820 {
821 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
822 }
823 if(clear_parent_script_UID)
824 {
825 parent_script_UID = 0;
826 }
827 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
828 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
829
830 for ( int32_t q = 0; q < 8; q++ )
831 {
832 initD[q] = other.initD[q];
833 weap_initiald[q] = other.weap_initiald[q];
834 }
835 for ( int32_t q = 0; q < 2; q++ )
836 {
837 initA[q] = other.initA[q];
838 weap_initiala[q] = other.weap_initiala[q];
839 }
840 }
841
842 eStalfos::eStalfos(eStalfos const & other, bool new_script_uid, bool clear_parent_script_UID):
843 //Struct Element Type Purpose
844 //sprite(other),
845 enemy(other),
846 clk4(other.clk4),
847 clk5(other.clk5),
848 fired(other.fired),
849 shield(other.shield),
850 dashing(other.dashing),
851 multishot(other.multishot),
852 fy(other.fy),
853 shadowdistance(other.shadowdistance)
854 {
855
856 //arrays
857
858 if(other.scrmem)
859 {
860 alloc_scriptmem();
861 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
862
863 scrmem->scriptData = other.scrmem->scriptData;
864 }
865 else scrmem = NULL;
866 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
867 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
868
869 for(int32_t i=0; i<edefLAST255; i++)
870 defense[i]=other.defense[i];
871 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
872 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
873
874 if(new_script_uid)
875 {
876 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
877 }
878 if(clear_parent_script_UID)
879 {
880 parent_script_UID = 0;
881 }
882 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
883 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
884
885 for ( int32_t q = 0; q < 8; q++ )
886 {
887 initD[q] = other.initD[q];
888 weap_initiald[q] = other.weap_initiald[q];
889 }
890 for ( int32_t q = 0; q < 2; q++ )
891 {
892 initA[q] = other.initA[q];
893 weap_initiala[q] = other.weap_initiala[q];
894 }
895 }
896
897 eZora::eZora(eZora const & other, bool new_script_uid, bool clear_parent_script_UID):
898 //Struct Element Type Purpose
899 //sprite(other),
900 enemy(other)
901 {
902
903 //arrays
904
905 if(other.scrmem)
906 {
907 alloc_scriptmem();
908 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
909
910 scrmem->scriptData = other.scrmem->scriptData;
911 }
912 else scrmem = NULL;
913 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
914 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
915
916 for(int32_t i=0; i<edefLAST255; i++)
917 defense[i]=other.defense[i];
918 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
919 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
920
921 if(new_script_uid)
922 {
923 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
924 }
925 if(clear_parent_script_UID)
926 {
927 parent_script_UID = 0;
928 }
929 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
930 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
931
932 for ( int32_t q = 0; q < 8; q++ )
933 {
934 initD[q] = other.initD[q];
935 weap_initiald[q] = other.weap_initiald[q];
936 }
937 for ( int32_t q = 0; q < 2; q++ )
938 {
939 initA[q] = other.initA[q];
940 weap_initiala[q] = other.weap_initiala[q];
941 }
942 }
943
944 eSpinTile::eSpinTile(eSpinTile const & other, bool new_script_uid, bool clear_parent_script_UID):
945 //Struct Element Type Purpose
946 //sprite(other),
947 enemy(other)
948 {
949
950 //arrays
951
952 if(other.scrmem)
953 {
954 alloc_scriptmem();
955 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
956
957 scrmem->scriptData = other.scrmem->scriptData;
958 }
959 else scrmem = NULL;
960 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
961 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
962
963 for(int32_t i=0; i<edefLAST255; i++)
964 defense[i]=other.defense[i];
965 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
966 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
967
968 if(new_script_uid)
969 {
970 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
971 }
972 if(clear_parent_script_UID)
973 {
974 parent_script_UID = 0;
975 }
976 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
977 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
978
979 for ( int32_t q = 0; q < 8; q++ )
980 {
981 initD[q] = other.initD[q];
982 weap_initiald[q] = other.weap_initiald[q];
983 }
984 for ( int32_t q = 0; q < 2; q++ )
985 {
986 initA[q] = other.initA[q];
987 weap_initiala[q] = other.weap_initiala[q];
988 }
989 }
990
991 eNPC::eNPC(eNPC const & other, bool new_script_uid, bool clear_parent_script_UID):
992 //Struct Element Type Purpose
993 //sprite(other),
994 enemy(other)
995 {
996
997 //arrays
998
999 if(other.scrmem)
1000 {
1001 alloc_scriptmem();
1002 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1003
1004 scrmem->scriptData = other.scrmem->scriptData;
1005 }
1006 else scrmem = NULL;
1007 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1008 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1009
1010 for(int32_t i=0; i<edefLAST255; i++)
1011 defense[i]=other.defense[i];
1012 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1013 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1014
1015 if(new_script_uid)
1016 {
1017 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1018 }
1019 if(clear_parent_script_UID)
1020 {
1021 parent_script_UID = 0;
1022 }
1023 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1024 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1025
1026 for ( int32_t q = 0; q < 8; q++ )
1027 {
1028 initD[q] = other.initD[q];
1029 weap_initiald[q] = other.weap_initiald[q];
1030 }
1031 for ( int32_t q = 0; q < 2; q++ )
1032 {
1033 initA[q] = other.initA[q];
1034 weap_initiala[q] = other.weap_initiala[q];
1035 }
1036 }
1037
1038 eTrigger::eTrigger(eTrigger const & other, bool new_script_uid, bool clear_parent_script_UID):
1039 //Struct Element Type Purpose
1040 //sprite(other),
1041 enemy(other)
1042 {
1043
1044 //arrays
1045
1046 if(other.scrmem)
1047 {
1048 alloc_scriptmem();
1049 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1050
1051 scrmem->scriptData = other.scrmem->scriptData;
1052 }
1053 else scrmem = NULL;
1054 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1055 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1056
1057 for(int32_t i=0; i<edefLAST255; i++)
1058 defense[i]=other.defense[i];
1059 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1060 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1061
1062 if(new_script_uid)
1063 {
1064 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1065 }
1066 if(clear_parent_script_UID)
1067 {
1068 parent_script_UID = 0;
1069 }
1070 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1071 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1072
1073 for ( int32_t q = 0; q < 8; q++ )
1074 {
1075 initD[q] = other.initD[q];
1076 weap_initiald[q] = other.weap_initiald[q];
1077 }
1078 for ( int32_t q = 0; q < 2; q++ )
1079 {
1080 initA[q] = other.initA[q];
1081 weap_initiala[q] = other.weap_initiala[q];
1082 }
1083 }
1084
1085 eProjectile::eProjectile(eProjectile const & other, bool new_script_uid, bool clear_parent_script_UID):
1086 //Struct Element Type Purpose
1087 //sprite(other),
1088 enemy(other),
1089 minRange(other.minRange)
1090 {
1091
1092 //arrays
1093
1094 if(other.scrmem)
1095 {
1096 alloc_scriptmem();
1097 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1098
1099 scrmem->scriptData = other.scrmem->scriptData;
1100 }
1101 else scrmem = NULL;
1102 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1103 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1104
1105 for(int32_t i=0; i<edefLAST255; i++)
1106 defense[i]=other.defense[i];
1107 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1108 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1109
1110 if(new_script_uid)
1111 {
1112 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1113 }
1114 if(clear_parent_script_UID)
1115 {
1116 parent_script_UID = 0;
1117 }
1118 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1119 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1120
1121 for ( int32_t q = 0; q < 8; q++ )
1122 {
1123 initD[q] = other.initD[q];
1124 weap_initiald[q] = other.weap_initiald[q];
1125 }
1126 for ( int32_t q = 0; q < 2; q++ )
1127 {
1128 initA[q] = other.initA[q];
1129 weap_initiala[q] = other.weap_initiala[q];
1130 }
1131 }
1132
1133 eBoulder::eBoulder(eBoulder const & other, bool new_script_uid, bool clear_parent_script_UID):
1134 //Struct Element Type Purpose
1135 //sprite(other),
1136 enemy(other)
1137 {
1138
1139 //arrays
1140
1141 if(other.scrmem)
1142 {
1143 alloc_scriptmem();
1144 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1145
1146 scrmem->scriptData = other.scrmem->scriptData;
1147 }
1148 else scrmem = NULL;
1149 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1150 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1151
1152 for(int32_t i=0; i<edefLAST255; i++)
1153 defense[i]=other.defense[i];
1154 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1155 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1156
1157 if(new_script_uid)
1158 {
1159 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1160 }
1161 if(clear_parent_script_UID)
1162 {
1163 parent_script_UID = 0;
1164 }
1165 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1166 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1167
1168 for ( int32_t q = 0; q < 8; q++ )
1169 {
1170 initD[q] = other.initD[q];
1171 weap_initiald[q] = other.weap_initiald[q];
1172 }
1173 for ( int32_t q = 0; q < 2; q++ )
1174 {
1175 initA[q] = other.initA[q];
1176 weap_initiala[q] = other.weap_initiala[q];
1177 }
1178 }
1179
1180 eRock::eRock(eRock const & other, bool new_script_uid, bool clear_parent_script_UID):
1181 //Struct Element Type Purpose
1182 //sprite(other),
1183 enemy(other)
1184 {
1185
1186 //arrays
1187
1188 if(other.scrmem)
1189 {
1190 alloc_scriptmem();
1191 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1192
1193 scrmem->scriptData = other.scrmem->scriptData;
1194 }
1195 else scrmem = NULL;
1196 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1197 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1198
1199 for(int32_t i=0; i<edefLAST255; i++)
1200 defense[i]=other.defense[i];
1201 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1202 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1203
1204 if(new_script_uid)
1205 {
1206 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1207 }
1208 if(clear_parent_script_UID)
1209 {
1210 parent_script_UID = 0;
1211 }
1212 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1213 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1214
1215 for ( int32_t q = 0; q < 8; q++ )
1216 {
1217 initD[q] = other.initD[q];
1218 weap_initiald[q] = other.weap_initiald[q];
1219 }
1220 for ( int32_t q = 0; q < 2; q++ )
1221 {
1222 initA[q] = other.initA[q];
1223 weap_initiala[q] = other.weap_initiala[q];
1224 }
1225 }
1226
1227 eTrap2::eTrap2(eTrap2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1228 //Struct Element Type Purpose
1229 //sprite(other),
1230 enemy(other)
1231 {
1232
1233 //arrays
1234
1235 if(other.scrmem)
1236 {
1237 alloc_scriptmem();
1238 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1239
1240 scrmem->scriptData = other.scrmem->scriptData;
1241 }
1242 else scrmem = NULL;
1243 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1244 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1245
1246 for(int32_t i=0; i<edefLAST255; i++)
1247 defense[i]=other.defense[i];
1248 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1249 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1250
1251 if(new_script_uid)
1252 {
1253 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1254 }
1255 if(clear_parent_script_UID)
1256 {
1257 parent_script_UID = 0;
1258 }
1259 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1260 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1261
1262 for ( int32_t q = 0; q < 8; q++ )
1263 {
1264 initD[q] = other.initD[q];
1265 weap_initiald[q] = other.weap_initiald[q];
1266 }
1267 for ( int32_t q = 0; q < 2; q++ )
1268 {
1269 initA[q] = other.initA[q];
1270 weap_initiala[q] = other.weap_initiala[q];
1271 }
1272 }
1273
1274 eTrap::eTrap(eTrap const & other, bool new_script_uid, bool clear_parent_script_UID):
1275 //Struct Element Type Purpose
1276 //sprite(other),
1277 enemy(other),
1278 ox(other.ox),
1279 oy(other.oy)
1280 {
1281
1282 //arrays
1283
1284 if(other.scrmem)
1285 {
1286 alloc_scriptmem();
1287 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1288
1289 scrmem->scriptData = other.scrmem->scriptData;
1290 }
1291 else scrmem = NULL;
1292 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1293 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1294
1295 for(int32_t i=0; i<edefLAST255; i++)
1296 defense[i]=other.defense[i];
1297 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1298 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1299
1300 if(new_script_uid)
1301 {
1302 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1303 }
1304 if(clear_parent_script_UID)
1305 {
1306 parent_script_UID = 0;
1307 }
1308 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1309 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1310
1311 for ( int32_t q = 0; q < 8; q++ )
1312 {
1313 initD[q] = other.initD[q];
1314 weap_initiald[q] = other.weap_initiald[q];
1315 }
1316 for ( int32_t q = 0; q < 2; q++ )
1317 {
1318 initA[q] = other.initA[q];
1319 weap_initiala[q] = other.weap_initiala[q];
1320 }
1321 }
1322
1323
1324
1325
1326 eKeese::eKeese(eKeese const & other, bool new_script_uid, bool clear_parent_script_UID):
1327 //Struct Element Type Purpose
1328 //sprite(other),
1329 enemy(other),
1330 ox(other.ox),
1331 c(other.c),
1332 clk4(other.clk4),
1333 oy(other.oy)
1334 {
1335
1336 //arrays
1337
1338 if(other.scrmem)
1339 {
1340 alloc_scriptmem();
1341 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1342
1343 scrmem->scriptData = other.scrmem->scriptData;
1344 }
1345 else scrmem = NULL;
1346 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1347 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1348
1349 for(int32_t i=0; i<edefLAST255; i++)
1350 defense[i]=other.defense[i];
1351 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1352 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1353
1354 if(new_script_uid)
1355 {
1356 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1357 }
1358 if(clear_parent_script_UID)
1359 {
1360 parent_script_UID = 0;
1361 }
1362 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1363 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1364
1365 for ( int32_t q = 0; q < 8; q++ )
1366 {
1367 initD[q] = other.initD[q];
1368 weap_initiald[q] = other.weap_initiald[q];
1369 }
1370 for ( int32_t q = 0; q < 2; q++ )
1371 {
1372 initA[q] = other.initA[q];
1373 weap_initiala[q] = other.weap_initiala[q];
1374 }
1375 }
1376
1377 eWizzrobe::eWizzrobe(eWizzrobe const & other, bool new_script_uid, bool clear_parent_script_UID):
1378 //Struct Element Type Purpose
1379 //sprite(other),
1380 enemy(other),
1381 charging(other.charging),
1382 firing(other.firing),
1383 fclk(other.fclk)
1384 {
1385
1386 //arrays
1387
1388 if(other.scrmem)
1389 {
1390 alloc_scriptmem();
1391 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1392
1393 scrmem->scriptData = other.scrmem->scriptData;
1394 }
1395 else scrmem = NULL;
1396 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1397 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1398
1399 for(int32_t i=0; i<edefLAST255; i++)
1400 defense[i]=other.defense[i];
1401 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1402 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1403
1404 if(new_script_uid)
1405 {
1406 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1407 }
1408 if(clear_parent_script_UID)
1409 {
1410 parent_script_UID = 0;
1411 }
1412 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1413 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1414
1415 for ( int32_t q = 0; q < 8; q++ )
1416 {
1417 initD[q] = other.initD[q];
1418 weap_initiald[q] = other.weap_initiald[q];
1419 }
1420 for ( int32_t q = 0; q < 2; q++ )
1421 {
1422 initA[q] = other.initA[q];
1423 weap_initiala[q] = other.weap_initiala[q];
1424 }
1425 }
1426
1427 eDodongo::eDodongo(eDodongo const & other, bool new_script_uid, bool clear_parent_script_UID):
1428 //Struct Element Type Purpose
1429 //sprite(other),
1430 enemy(other)
1431 {
1432
1433 //arrays
1434
1435 if(other.scrmem)
1436 {
1437 alloc_scriptmem();
1438 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1439
1440 scrmem->scriptData = other.scrmem->scriptData;
1441 }
1442 else scrmem = NULL;
1443 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1444 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1445
1446 for(int32_t i=0; i<edefLAST255; i++)
1447 defense[i]=other.defense[i];
1448 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1449 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1450
1451 if(new_script_uid)
1452 {
1453 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1454 }
1455 if(clear_parent_script_UID)
1456 {
1457 parent_script_UID = 0;
1458 }
1459 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1460 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1461
1462 for ( int32_t q = 0; q < 8; q++ )
1463 {
1464 initD[q] = other.initD[q];
1465 weap_initiald[q] = other.weap_initiald[q];
1466 }
1467 for ( int32_t q = 0; q < 2; q++ )
1468 {
1469 initA[q] = other.initA[q];
1470 weap_initiala[q] = other.weap_initiala[q];
1471 }
1472 }
1473
1474 eDodongo2::eDodongo2(eDodongo2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1475 //Struct Element Type Purpose
1476 //sprite(other),
1477 enemy(other),
1478 previous_dir(other.previous_dir)
1479 {
1480
1481 //arrays
1482
1483 if(other.scrmem)
1484 {
1485 alloc_scriptmem();
1486 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1487
1488 scrmem->scriptData = other.scrmem->scriptData;
1489 }
1490 else scrmem = NULL;
1491 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1492 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1493
1494 for(int32_t i=0; i<edefLAST255; i++)
1495 defense[i]=other.defense[i];
1496 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1497 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1498
1499 if(new_script_uid)
1500 {
1501 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1502 }
1503 if(clear_parent_script_UID)
1504 {
1505 parent_script_UID = 0;
1506 }
1507 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1508 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1509
1510 for ( int32_t q = 0; q < 8; q++ )
1511 {
1512 initD[q] = other.initD[q];
1513 weap_initiald[q] = other.weap_initiald[q];
1514 }
1515 for ( int32_t q = 0; q < 2; q++ )
1516 {
1517 initA[q] = other.initA[q];
1518 weap_initiala[q] = other.weap_initiala[q];
1519 }
1520 }
1521
1522 eAquamentus::eAquamentus(eAquamentus const & other, bool new_script_uid, bool clear_parent_script_UID):
1523 //Struct Element Type Purpose
1524 //sprite(other),
1525 enemy(other),
1526 fbx(other.fbx),
1527 clk4(other.clk4)
1528 {
1529
1530 //arrays
1531
1532 if(other.scrmem)
1533 {
1534 alloc_scriptmem();
1535 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1536
1537 scrmem->scriptData = other.scrmem->scriptData;
1538 }
1539 else scrmem = NULL;
1540 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1541 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1542
1543 for(int32_t i=0; i<edefLAST255; i++)
1544 defense[i]=other.defense[i];
1545 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1546 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1547
1548 if(new_script_uid)
1549 {
1550 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1551 }
1552 if(clear_parent_script_UID)
1553 {
1554 parent_script_UID = 0;
1555 }
1556 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1557 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1558
1559 for ( int32_t q = 0; q < 8; q++ )
1560 {
1561 initD[q] = other.initD[q];
1562 weap_initiald[q] = other.weap_initiald[q];
1563 }
1564 for ( int32_t q = 0; q < 2; q++ )
1565 {
1566 initA[q] = other.initA[q];
1567 weap_initiala[q] = other.weap_initiala[q];
1568 }
1569 }
1570
1571 eGohma::eGohma(eGohma const & other, bool new_script_uid, bool clear_parent_script_UID):
1572 //Struct Element Type Purpose
1573 //sprite(other),
1574 enemy(other),
1575 clk4(other.clk4)
1576 {
1577
1578 //arrays
1579
1580 if(other.scrmem)
1581 {
1582 alloc_scriptmem();
1583 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1584
1585 scrmem->scriptData = other.scrmem->scriptData;
1586 }
1587 else scrmem = NULL;
1588 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1589 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1590
1591 for(int32_t i=0; i<edefLAST255; i++)
1592 defense[i]=other.defense[i];
1593 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1594 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1595
1596 if(new_script_uid)
1597 {
1598 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1599 }
1600 if(clear_parent_script_UID)
1601 {
1602 parent_script_UID = 0;
1603 }
1604 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1605 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1606
1607 for ( int32_t q = 0; q < 8; q++ )
1608 {
1609 initD[q] = other.initD[q];
1610 weap_initiald[q] = other.weap_initiald[q];
1611 }
1612 for ( int32_t q = 0; q < 2; q++ )
1613 {
1614 initA[q] = other.initA[q];
1615 weap_initiala[q] = other.weap_initiala[q];
1616 }
1617 }
1618
1619 eLilDig::eLilDig(eLilDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1620 //Struct Element Type Purpose
1621 //sprite(other),
1622 enemy(other)
1623 {
1624
1625 //arrays
1626
1627 if(other.scrmem)
1628 {
1629 alloc_scriptmem();
1630 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1631
1632 scrmem->scriptData = other.scrmem->scriptData;
1633 }
1634 else scrmem = NULL;
1635 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1636 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1637
1638 for(int32_t i=0; i<edefLAST255; i++)
1639 defense[i]=other.defense[i];
1640 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1641 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1642
1643 if(new_script_uid)
1644 {
1645 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1646 }
1647 if(clear_parent_script_UID)
1648 {
1649 parent_script_UID = 0;
1650 }
1651 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1652 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1653
1654 for ( int32_t q = 0; q < 8; q++ )
1655 {
1656 initD[q] = other.initD[q];
1657 weap_initiald[q] = other.weap_initiald[q];
1658 }
1659 for ( int32_t q = 0; q < 2; q++ )
1660 {
1661 initA[q] = other.initA[q];
1662 weap_initiala[q] = other.weap_initiala[q];
1663 }
1664 }
1665
1666 eBigDig::eBigDig(eBigDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1667 //Struct Element Type Purpose
1668 //sprite(other),
1669 enemy(other)
1670 {
1671
1672 //arrays
1673
1674 if(other.scrmem)
1675 {
1676 alloc_scriptmem();
1677 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1678
1679 scrmem->scriptData = other.scrmem->scriptData;
1680 }
1681 else scrmem = NULL;
1682 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1683 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1684
1685 for(int32_t i=0; i<edefLAST255; i++)
1686 defense[i]=other.defense[i];
1687 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1688 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1689
1690 if(new_script_uid)
1691 {
1692 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1693 }
1694 if(clear_parent_script_UID)
1695 {
1696 parent_script_UID = 0;
1697 }
1698 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1699 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1700
1701 for ( int32_t q = 0; q < 8; q++ )
1702 {
1703 initD[q] = other.initD[q];
1704 weap_initiald[q] = other.weap_initiald[q];
1705 }
1706 for ( int32_t q = 0; q < 2; q++ )
1707 {
1708 initA[q] = other.initA[q];
1709 weap_initiala[q] = other.weap_initiala[q];
1710 }
1711 }
1712
1713 eGanon::eGanon(eGanon const & other, bool new_script_uid, bool clear_parent_script_UID):
1714 //Struct Element Type Purpose
1715 //sprite(other),
1716 enemy(other),
1717 Stunclk(other.Stunclk)
1718
1719 {
1720
1721 //arrays
1722
1723 if(other.scrmem)
1724 {
1725 alloc_scriptmem();
1726 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1727
1728 scrmem->scriptData = other.scrmem->scriptData;
1729 }
1730 else scrmem = NULL;
1731 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1732 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1733
1734 for(int32_t i=0; i<edefLAST255; i++)
1735 defense[i]=other.defense[i];
1736 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1737 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1738
1739 if(new_script_uid)
1740 {
1741 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1742 }
1743 if(clear_parent_script_UID)
1744 {
1745 parent_script_UID = 0;
1746 }
1747 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1748 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1749
1750 for ( int32_t q = 0; q < 8; q++ )
1751 {
1752 initD[q] = other.initD[q];
1753 weap_initiald[q] = other.weap_initiald[q];
1754 }
1755 for ( int32_t q = 0; q < 2; q++ )
1756 {
1757 initA[q] = other.initA[q];
1758 weap_initiala[q] = other.weap_initiala[q];
1759 }
1760 }
1761
1762 eMoldorm::eMoldorm(eMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1763 //Struct Element Type Purpose
1764 //sprite(other),
1765 enemy(other),
1766 segcnt(other.segcnt),
1767 segid(other.segid)
1768
1769 {
1770
1771 //arrays
1772
1773 if(other.scrmem)
1774 {
1775 alloc_scriptmem();
1776 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1777
1778 scrmem->scriptData = other.scrmem->scriptData;
1779 }
1780 else scrmem = NULL;
1781 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1782 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1783
1784 for(int32_t i=0; i<edefLAST255; i++)
1785 defense[i]=other.defense[i];
1786 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1787 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1788
1789 if(new_script_uid)
1790 {
1791 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1792 }
1793 if(clear_parent_script_UID)
1794 {
1795 parent_script_UID = 0;
1796 }
1797 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1798 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1799
1800 for ( int32_t q = 0; q < 8; q++ )
1801 {
1802 initD[q] = other.initD[q];
1803 weap_initiald[q] = other.weap_initiald[q];
1804 }
1805 for ( int32_t q = 0; q < 2; q++ )
1806 {
1807 initA[q] = other.initA[q];
1808 weap_initiala[q] = other.weap_initiala[q];
1809 }
1810 }
1811
1812 esMoldorm::esMoldorm(esMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1813 //Struct Element Type Purpose
1814 //sprite(other),
1815 enemy(other),
1816 parentclk(other.parentclk)
1817 {
1818
1819 //arrays
1820
1821 if(other.scrmem)
1822 {
1823 alloc_scriptmem();
1824 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1825
1826 scrmem->scriptData = other.scrmem->scriptData;
1827 }
1828 else scrmem = NULL;
1829 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1830 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1831
1832 for(int32_t i=0; i<edefLAST255; i++)
1833 defense[i]=other.defense[i];
1834 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1835 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1836
1837 if(new_script_uid)
1838 {
1839 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1840 }
1841 if(clear_parent_script_UID)
1842 {
1843 parent_script_UID = 0;
1844 }
1845 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1846 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1847
1848 for ( int32_t q = 0; q < 8; q++ )
1849 {
1850 initD[q] = other.initD[q];
1851 weap_initiald[q] = other.weap_initiald[q];
1852 }
1853 for ( int32_t q = 0; q < 2; q++ )
1854 {
1855 initA[q] = other.initA[q];
1856 weap_initiala[q] = other.weap_initiala[q];
1857 }
1858 }
1859 /*
1860 eManhandla::eManhandla(eManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1861 //Struct Element Type Purpose
1862 //sprite(other),
1863 enemy(other),
1864 armcnt(armcnt),
1865 adjusted(adjusted),
1866 arm[0](arm[0]),
1867 arm[1](arm[1]),
1868 arm[2](arm[2]),
1869 arm[3](arm[3]),
1870 arm[4](arm[4]),
1871 arm[5](arm[5]),
1872 arm[6](arm[6]),
1873 arm[7](arm[7])
1874 {
1875
1876 //arrays
1877 if(other.scrmem)
1878 {
1879 alloc_scriptmem();
1880 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1881
1882 scrmem->scriptData = other.scrmem->scriptData;
1883 }
1884 else scrmem = NULL;
1885 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1886 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1887
1888 for(int32_t i=0; i<edefLAST255; i++)
1889 defense[i]=other.defense[i];
1890 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1891 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1892
1893 if(new_script_uid)
1894 {
1895 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1896 }
1897 if(clear_parent_script_UID)
1898 {
1899 parent_script_UID = 0;
1900 }
1901 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1902 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1903
1904 for ( int32_t q = 0; q < 8; q++ )
1905 {
1906 initD[q] = other.initD[q];
1907 weap_initiald[q] = other.weap_initiald[q];
1908 }
1909 for ( int32_t q = 0; q < 2; q++ )
1910 {
1911 initA[q] = other.initA[q];
1912 weap_initiala[q] = other.weap_initiala[q];
1913 }
1914 }
1915
1916 esManhandla::esManhandla(esManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1917 //Struct Element Type Purpose
1918 //sprite(other),
1919 enemy(other)
1920 {
1921
1922 //arrays
1923 if(other.scrmem)
1924 {
1925 alloc_scriptmem();
1926 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1927
1928 scrmem->scriptData = other.scrmem->scriptData;
1929 }
1930 else scrmem = NULL;
1931 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1932 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1933
1934 for(int32_t i=0; i<edefLAST255; i++)
1935 defense[i]=other.defense[i];
1936 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1937 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1938
1939 if(new_script_uid)
1940 {
1941 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1942 }
1943 if(clear_parent_script_UID)
1944 {
1945 parent_script_UID = 0;
1946 }
1947 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1948 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1949
1950 for ( int32_t q = 0; q < 8; q++ )
1951 {
1952 initD[q] = other.initD[q];
1953 weap_initiald[q] = other.weap_initiald[q];
1954 }
1955 for ( int32_t q = 0; q < 2; q++ )
1956 {
1957 initA[q] = other.initA[q];
1958 weap_initiala[q] = other.weap_initiala[q];
1959 }
1960 }
1961
1962 eGleeok::eGleeok(eGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
1963 //Struct Element Type Purpose
1964 //sprite(other),
1965 enemy(other),
1966 flameclk(flameclk),
1967 flamehead(flamehead),
1968 necktile(necktile)
1969
1970 {
1971
1972 //arrays
1973
1974 if(other.scrmem)
1975 {
1976 alloc_scriptmem();
1977 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1978
1979 scrmem->scriptData = other.scrmem->scriptData;
1980 }
1981 else scrmem = NULL;
1982 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1983 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1984
1985 for(int32_t i=0; i<edefLAST255; i++)
1986 defense[i]=other.defense[i];
1987 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1988 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1989
1990 if(new_script_uid)
1991 {
1992 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1993 }
1994 if(clear_parent_script_UID)
1995 {
1996 parent_script_UID = 0;
1997 }
1998 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1999 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2000
2001 for ( int32_t q = 0; q < 8; q++ )
2002 {
2003 initD[q] = other.initD[q];
2004 weap_initiald[q] = other.weap_initiald[q];
2005 }
2006 for ( int32_t q = 0; q < 2; q++ )
2007 {
2008 initA[q] = other.initA[q];
2009 weap_initiala[q] = other.weap_initiala[q];
2010 }
2011 }
2012
2013 esGleeok::esGleeok(esGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
2014 //Struct Element Type Purpose
2015 //sprite(other),
2016 enemy(other),
2017 headtile(headtile),
2018 flyingheadtile(flyingheadtile),
2019 necktile(necktile),
2020 xoffset(xoffset),
2021 yoffset(yoffset),
2022 nx(nx),
2023 ny(ny),
2024 nxoffset(nxoffset),
2025 nyoffset(nyoffset),
2026 parent(parent)
2027
2028 {
2029
2030 //arrays
2031
2032 if(other.scrmem)
2033 {
2034 alloc_scriptmem();
2035 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2036
2037 scrmem->scriptData = other.scrmem->scriptData;
2038 }
2039 else scrmem = NULL;
2040 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2041 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2042
2043 //for ( int32_t q = 0; q < 255; q++ )
2044 //{
2045 // nx[q] = other.nx[q];
2046 // ny[q] = other.ny[q];
2047 // nxoffset[q] = other.nxoffset[q];
2048 // nyoffset[q] = other.nyoffset[q];
2049 //}
2050
2051 for(int32_t i=0; i<edefLAST255; i++)
2052 defense[i]=other.defense[i];
2053 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2054 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2055
2056 if(new_script_uid)
2057 {
2058 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2059 }
2060 if(clear_parent_script_UID)
2061 {
2062 parent_script_UID = 0;
2063 }
2064 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2065 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2066
2067 for ( int32_t q = 0; q < 8; q++ )
2068 {
2069 initD[q] = other.initD[q];
2070 weap_initiald[q] = other.weap_initiald[q];
2071 }
2072 for ( int32_t q = 0; q < 2; q++ )
2073 {
2074 initA[q] = other.initA[q];
2075 weap_initiala[q] = other.weap_initiala[q];
2076 }
2077 }
2078
2079 ePatra::ePatra(ePatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2080 //Struct Element Type Purpose
2081 //sprite(other),
2082 enemy(other),
2083 flycnt(flycnt),
2084 flycnt2(flycnt2),
2085 loopcnt(loopcnt),
2086 lookat(lookat),
2087 circle_x(circle_x),
2088 circle_y(circle_y),
2089 temp_x(temp_x),
2090 temp_y(temp_y),
2091 adjusted(adjusted)
2092
2093 {
2094
2095 //arrays
2096
2097 if(other.scrmem)
2098 {
2099 alloc_scriptmem();
2100 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2101
2102 scrmem->scriptData = other.scrmem->scriptData;
2103 }
2104 else scrmem = NULL;
2105 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2106 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2107
2108 for(int32_t i=0; i<edefLAST255; i++)
2109 defense[i]=other.defense[i];
2110 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2111 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2112
2113 if(new_script_uid)
2114 {
2115 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2116 }
2117 if(clear_parent_script_UID)
2118 {
2119 parent_script_UID = 0;
2120 }
2121 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2122 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2123
2124 for ( int32_t q = 0; q < 8; q++ )
2125 {
2126 initD[q] = other.initD[q];
2127 weap_initiald[q] = other.weap_initiald[q];
2128 }
2129 for ( int32_t q = 0; q < 2; q++ )
2130 {
2131 initA[q] = other.initA[q];
2132 weap_initiala[q] = other.weap_initiala[q];
2133 }
2134 }
2135
2136 ePatraBS::ePatraBS(ePatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2137 //Struct Element Type Purpose
2138 //sprite(other),
2139 enemy(other),
2140 flycnt(flycnt),
2141 flycnt2(flycnt2),
2142 loopcnt(loopcnt),
2143 lookat(lookat),
2144 adjusted(adjusted)
2145
2146 {
2147
2148 //arrays
2149
2150 if(other.scrmem)
2151 {
2152 alloc_scriptmem();
2153 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2154
2155 scrmem->scriptData = other.scrmem->scriptData;
2156 }
2157 else scrmem = NULL;
2158 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2159 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2160
2161 for(int32_t i=0; i<edefLAST255; i++)
2162 defense[i]=other.defense[i];
2163 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2164 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2165
2166 if(new_script_uid)
2167 {
2168 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2169 }
2170 if(clear_parent_script_UID)
2171 {
2172 parent_script_UID = 0;
2173 }
2174 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2175 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2176
2177 for ( int32_t q = 0; q < 8; q++ )
2178 {
2179 initD[q] = other.initD[q];
2180 weap_initiald[q] = other.weap_initiald[q];
2181 }
2182 for ( int32_t q = 0; q < 2; q++ )
2183 {
2184 initA[q] = other.initA[q];
2185 weap_initiala[q] = other.weap_initiala[q];
2186 }
2187 }
2188
2189 esPatra::esPatra(esPatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2190 //Struct Element Type Purpose
2191 //sprite(other),
2192 enemy(other)
2193
2194 {
2195
2196 //arrays
2197
2198 if(other.scrmem)
2199 {
2200 alloc_scriptmem();
2201 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2202
2203 scrmem->scriptData = other.scrmem->scriptData;
2204 }
2205 else scrmem = NULL;
2206 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2207 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2208
2209 for ( int32_t q = 0; q < 255; q++ )
2210 {
2211 nx[q] = other.nx[q];
2212 ny[q] = other.ny[q];
2213 nxoffset[q] = other.nxoffset[q];
2214 nyoffset[q] = other.nyoffset[q];
2215 }
2216
2217 for(int32_t i=0; i<edefLAST255; i++)
2218 defense[i]=other.defense[i];
2219 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2220 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2221
2222 if(new_script_uid)
2223 {
2224 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2225 }
2226 if(clear_parent_script_UID)
2227 {
2228 parent_script_UID = 0;
2229 }
2230 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2231 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2232
2233 for ( int32_t q = 0; q < 8; q++ )
2234 {
2235 initD[q] = other.initD[q];
2236 weap_initiald[q] = other.weap_initiald[q];
2237 }
2238 for ( int32_t q = 0; q < 2; q++ )
2239 {
2240 initA[q] = other.initA[q];
2241 weap_initiala[q] = other.weap_initiala[q];
2242 }
2243 }
2244
2245 esPatraBS::esPatraBS(esPatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2246 //Struct Element Type Purpose
2247 //sprite(other),
2248 enemy(other)
2249
2250 {
2251
2252 //arrays
2253
2254 if(other.scrmem)
2255 {
2256 alloc_scriptmem();
2257 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2258
2259 scrmem->scriptData = other.scrmem->scriptData;
2260 }
2261 else scrmem = NULL;
2262 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2263 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2264
2265 for ( int32_t q = 0; q < 255; q++ )
2266 {
2267 nx[q] = other.nx[q];
2268 ny[q] = other.ny[q];
2269 nxoffset[q] = other.nxoffset[q];
2270 nyoffset[q] = other.nyoffset[q];
2271 }
2272
2273 for(int32_t i=0; i<edefLAST255; i++)
2274 defense[i]=other.defense[i];
2275 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2276 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2277
2278 if(new_script_uid)
2279 {
2280 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2281 }
2282 if(clear_parent_script_UID)
2283 {
2284 parent_script_UID = 0;
2285 }
2286 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2287 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2288
2289 for ( int32_t q = 0; q < 8; q++ )
2290 {
2291 initD[q] = other.initD[q];
2292 weap_initiald[q] = other.weap_initiald[q];
2293 }
2294 for ( int32_t q = 0; q < 2; q++ )
2295 {
2296 initA[q] = other.initA[q];
2297 weap_initiala[q] = other.weap_initiala[q];
2298 }
2299 }
2300
2301 */
2302
2303
5/10
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48784 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48784 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 48784 times.
✗ Branch 9 not taken.
146352 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
2304 97568 {
2305
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 x=X;
2306
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 y=Y;
2307 48784 id=Id;
2308 48784 clk=Clk;
2309
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 floor_y=y;
2310 48784 ceiling=false;
2311 48784 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
2312 48784 grumble = movestatus = posframe = timer = ox = oy = 0;
2313
4/8
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48784 times.
✓ Branch 4 taken 48784 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48784 times.
✗ Branch 7 not taken.
48784 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
2314 48784 did_armos=true;
2315 48784 script_spawned=false;
2316
2317 48784 d = guysbuf + (id & 0xFFF);
2318 48784 hp = d->hp;
2319 48784 starting_hp = hp;
2320 // cs = d->cset;
2321 //d variables
2322
2323 48784 flags=d->flags;
2324 48784 flags2=d->flags2;
2325 48784 s_tile=d->s_tile; //secondary (additional) tile(s)
2326 48784 family=d->family;
2327 48784 dcset=d->cset;
2328 48784 cs=dcset;
2329
3/4
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29494 times.
✓ Branch 3 taken 19290 times.
48784 anim=get_bit(quest_rules,qr_NEWENEMYTILES)?d->e_anim:d->anim;
2330 48784 dp=d->dp;
2331 48784 wdp=d->wdp;
2332 48784 wpn=d->weapon;
2333 48784 wpnsprite = d-> wpnsprite; //2.6 -Z
2334 48784 rate=d->rate;
2335 48784 hrate=d->hrate;
2336
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 dstep=d->step;
2337 48784 homing=d->homing;
2338 48784 dmisc1=d->misc1;
2339 48784 dmisc2=d->misc2;
2340 48784 dmisc3=d->misc3;
2341 48784 dmisc4=d->misc4;
2342 48784 dmisc5=d->misc5;
2343 48784 dmisc6=d->misc6;
2344 48784 dmisc7=d->misc7;
2345 48784 dmisc8=d->misc8;
2346 48784 dmisc9=d->misc9;
2347 48784 dmisc10=d->misc10;
2348 48784 dmisc11=d->misc11;
2349 48784 dmisc12=d->misc12;
2350 48784 dmisc13=d->misc13;
2351 48784 dmisc14=d->misc14;
2352 48784 dmisc15=d->misc15;
2353 48784 dmisc16=d->misc16;
2354 48784 dmisc17=d->misc17;
2355 48784 dmisc18=d->misc18;
2356 48784 dmisc19=d->misc19;
2357 48784 dmisc20=d->misc20;
2358 48784 dmisc21=d->misc21;
2359 48784 dmisc22=d->misc22;
2360 48784 dmisc23=d->misc23;
2361 48784 dmisc24=d->misc24;
2362 48784 dmisc25=d->misc25;
2363 48784 dmisc26=d->misc26;
2364 48784 dmisc27=d->misc27;
2365 48784 dmisc28=d->misc28;
2366 48784 dmisc29=d->misc29;
2367 48784 dmisc30=d->misc30;
2368 48784 dmisc31=d->misc31;
2369 48784 dmisc32=d->misc32;
2370
3/4
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48280 times.
✓ Branch 3 taken 504 times.
48784 if (get_bit(quest_rules, qr_BROKEN_ATTRIBUTE_31_32))
2371 {
2372 48280 dmisc31 = dmisc32;
2373 48280 dmisc32 = 0;
2374 48280 }
2375 48784 spr_shadow=d->spr_shadow;
2376 48784 spr_death=d->spr_death;
2377 48784 spr_spawn=d->spr_spawn;
2378
2379
2/2
✓ Branch 0 taken 2000144 times.
✓ Branch 1 taken 48784 times.
2048928 for(int32_t i=0; i<edefLAST255; i++)
2380 2000144 defense[i]=d->defense[i];
2381
2382 48784 bgsfx=d->bgsfx;
2383 48784 hitsfx=d->hitsfx;
2384 48784 deadsfx=d->deadsfx;
2385 48784 bosspal=d->bosspal;
2386 48784 parent_script_UID = 0;
2387
2388 48784 frozentile = d->frozentile;
2389
2390 48784 frozencset = d->frozencset;
2391 48784 frozenclock = 0;
2392
2/2
✓ Branch 0 taken 487840 times.
✓ Branch 1 taken 48784 times.
536624 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
2393
2394
2/2
✓ Branch 0 taken 48784 times.
✓ Branch 1 taken 829328 times.
878112 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
2395 //firesfx = 0; //t.b.a -Z
2396 48784 isCore = true; //t.b.a
2397 48784 parentCore = 0; //t.b.a
2398
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2399
2400 48784 firesfx = d->firesfx;
2401
2/2
✓ Branch 0 taken 1561088 times.
✓ Branch 1 taken 48784 times.
1609872 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
2402
2/2
✓ Branch 0 taken 1561088 times.
✓ Branch 1 taken 48784 times.
1609872 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
2403
2404
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
2405 48784 waitdraw = 0;
2406
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
2407
2408
2/2
✓ Branch 0 taken 390272 times.
✓ Branch 1 taken 48784 times.
439056 for ( int32_t q = 0; q < 8; q++ )
2409 {
2410 390272 initD[q] = d->initD[q];
2411 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
2412 390272 weap_initiald[q] = d->weap_initiald[q];
2413 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
2414 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
2415 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
2416 390272 }
2417
2/2
✓ Branch 0 taken 97568 times.
✓ Branch 1 taken 48784 times.
146352 for ( int32_t q = 0; q < 2; q++ )
2418 {
2419 97568 initA[q] = d->initA[q];
2420 97568 weap_initiala[q] = d->weap_initiala[q];
2421 97568 }
2422
2423 48784 stickclk = 0;
2424 48784 submerged = false;
2425 48784 ffcactivated = 0;
2426 48784 hitdir = -1;
2427 48784 dialogue_str = 0; //set by spawn flags.
2428 48784 editorflags = d->editorflags; //set by Enemy Editor
2429 //Set the drawing flag for this sprite.
2430
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
2431
2432
2433
2/2
✓ Branch 0 taken 7492 times.
✓ Branch 1 taken 41292 times.
48784 if(bosspal>-1)
2434 {
2435
1/2
✓ Branch 0 taken 7492 times.
✗ Branch 1 not taken.
7492 loadpalset(csBOSS,pSprite(bosspal));
2436 7492 }
2437
2438
2/2
✓ Branch 0 taken 22051 times.
✓ Branch 1 taken 26733 times.
48784 if(bgsfx>-1)
2439 {
2440
1/2
✓ Branch 0 taken 22051 times.
✗ Branch 1 not taken.
22051 cont_sfx(bgsfx);
2441 22051 }
2442
2443
3/4
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29494 times.
✓ Branch 3 taken 19290 times.
48784 if(get_bit(quest_rules,qr_NEWENEMYTILES))
2444 {
2445 29494 o_tile=d->e_tile;
2446 29494 frate = d->e_frate;
2447 29494 }
2448 else
2449 {
2450 19290 o_tile=d->tile;
2451 19290 frate = d->frate;
2452 }
2453
2454 48784 tile=0; //init to 0 here, but set it later.
2455
2456 48784 scripttile = -1;
2457 48784 scriptflip = -1;
2458 48784 do_animation = 1;
2459 48784 immortal = false;
2460 48784 noSlide = false;
2461 48784 deathexstate = -1;
2462
2463 48784 hashero=false;
2464
2465 // If they forgot the invisibility flag, here's another failsafe:
2466
4/4
✓ Branch 0 taken 2631 times.
✓ Branch 1 taken 46153 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2537 times.
48784 if(o_tile==0 && family!=eeSPINTILE)
2467 2537 flags |= guy_invisible;
2468
2469 // step = d->step/100.0;
2470 // To preserve the odd step values for Keese & Gleeok heads. -L
2471
5/8
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5685 times.
✓ Branch 5 taken 43099 times.
✓ Branch 6 taken 5685 times.
✗ Branch 7 not taken.
48784 if(dstep==62.0) dstep+=0.5;
2472
5/8
✓ Branch 0 taken 43099 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43099 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 345 times.
✓ Branch 5 taken 42754 times.
✓ Branch 6 taken 345 times.
✗ Branch 7 not taken.
43099 else if(dstep==89) dstep-=1/9;
2473
2474
5/10
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48784 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48784 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 48784 times.
✗ Branch 9 not taken.
48784 step = zslongToFix(dstep*100);
2475
2476
2477 48784 item_set = d->item_set;
2478 48784 grumble = d->grumble;
2479
2480
2/2
✓ Branch 0 taken 37979 times.
✓ Branch 1 taken 10805 times.
48784 if(frate == 0)
2481 10805 frate = 256;
2482
2483 48784 leader = itemguy = dying = scored = false;
2484 48784 canfreeze = count_enemy = true;
2485 48784 mainguy = !(flags & guy_doesntcount);
2486
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 dir = zc_oldrand()&3;
2487
2488 //2.6 Enemy Editor Hit and TIle Sizes
2489
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48784 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2490 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
2491 // al_trace("Enemy txsz:%i\n", txsz);
2492
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
48784 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
2493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48784 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
2494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48784 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
2495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48784 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
2496
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
2497
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
2498 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
2499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48784 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
2500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
48784 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2501 {
2502 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
2503 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2504 }
2505
2506
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48784 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
2507
2508 48784 SIZEflags = d->SIZEflags;
2509
2510
8/10
✓ Branch 0 taken 48696 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 48696 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
48784 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
2511 1 wpn = 0;
2512
2513 //tile should never be 0 after init --Z (failsafe)
2514
4/6
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47715 times.
✓ Branch 5 taken 1069 times.
48784 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
2515
2516 //Moveflags; for gravity and pit interaction
2517 48784 moveflags = d->moveflags;
2518
3/4
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41721 times.
✓ Branch 3 taken 7063 times.
48784 if(!can_pitfall(false))
2519 {
2520 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
2521 7063 moveflags &= ~FLAG_CAN_PITFALL;
2522 7063 moveflags &= ~FLAG_CAN_WATERDROWN;
2523 7063 }
2524
2525
1/2
✓ Branch 0 taken 48784 times.
✗ Branch 1 not taken.
48784 shieldCanBlock = get_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG)?true:false;
2526 48784 }
2527
2528 //base clone constructor
2529
2530 enemy::enemy(enemy const & other, bool new_script_uid, bool clear_parent_script_UID):
2531 //Struct Element Type Purpose
2532 sprite(other),
2533 //x(other.x), //int32_t
2534 //y(other.y), //int32_t
2535 //id(other.id), //int32_t
2536 //clk(other.clk), //int32_t
2537 floor_y(other.floor_y), //int32_t
2538 fading(other.fading), //int32_t
2539 //misc(other.misc), //int32_t
2540 clk2(other.clk2), //int32_t
2541 clk3(other.clk3), //int32_t
2542 stunclk(other.stunclk), //int32_t
2543 hclk(other.hclk), //int32_t
2544 sclk(other.sclk), //int32_t
2545 superman(other.superman), //int32_t
2546 //grumble(other.grumble), //int32_t
2547 movestatus(other.movestatus), //int32_t
2548 posframe(other.posframe), //int32_t
2549 timer(other.timer), //int32_t
2550 ox(other.ox), //int32_t
2551 oy(other.oy), //int32_t
2552 //yofs(other.yofs), //int32_t
2553 did_armos(other.did_armos), //int32_t
2554 script_spawned(other.script_spawned), //int32_t
2555 d(other.d), //int32_t
2556 hp(other.hp), //int32_t
2557 starting_hp(other.starting_hp), //int32_t
2558 //flags(other.flags), //int32_t
2559
2560 flags2(other.flags2), //int32_t
2561 s_tile(other.s_tile), //int32_t
2562 family(other.family), //int32_t
2563 dcset(other.dcset), //int32_t
2564 //cs(other.cs), //int32_t
2565 anim(other.anim), //int32_t
2566 dp(other.dp), //int32_t
2567 wdp(other.wdp), //int32_t
2568 wpnsprite(other.wpnsprite), //int32_t
2569 rate(other.rate), //int32_t
2570 hrate(other.hrate), //int32_t
2571 dstep(other.dstep), //int32_t
2572
2573 homing(other.homing), //int32_t
2574 dmisc1(other.dmisc1), //int32_t
2575 dmisc2(other.dmisc2), //int32_t
2576 dmisc3(other.dmisc3), //int32_t
2577 dmisc4(other.dmisc4), //int32_t
2578 dmisc5(other.dmisc5), //int32_t
2579 dmisc6(other.dmisc6), //int32_t
2580 dmisc7(other.dmisc7), //int32_t
2581 dmisc8(other.dmisc8), //int32_t
2582 dmisc9(other.dmisc9), //int32_t
2583 dmisc10(other.dmisc10), //int32_t
2584 dmisc11(other.dmisc11), //int32_t
2585 dmisc12(other.dmisc12), //int32_t
2586 dmisc13(other.dmisc13), //int32_t
2587 dmisc14(other.dmisc14), //int32_t
2588 dmisc15(other.dmisc15), //int32_t
2589 dmisc16(other.dmisc16), //int32_t
2590 dmisc17(other.dmisc17), //int32_t
2591 dmisc18(other.dmisc18), //int32_t
2592 dmisc19(other.dmisc19), //int32_t
2593 dmisc20(other.dmisc20), //int32_t
2594 dmisc21(other.dmisc21), //int32_t
2595 dmisc22(other.dmisc22), //int32_t
2596 dmisc23(other.dmisc23), //int32_t
2597 dmisc24(other.dmisc24), //int32_t
2598 dmisc25(other.dmisc25), //int32_t
2599 dmisc26(other.dmisc26), //int32_t
2600 dmisc27(other.dmisc27), //int32_t
2601 dmisc28(other.dmisc28), //int32_t
2602 dmisc29(other.dmisc29), //int32_t
2603 dmisc30(other.dmisc30), //int32_t
2604 dmisc31(other.dmisc31), //int32_t
2605 dmisc32(other.dmisc32), //int32_t
2606 bgsfx(other.bgsfx), //int32_t
2607 hitsfx(other.hitsfx), //int32_t
2608 deadsfx(other.deadsfx), //int32_t
2609 bosspal(other.bosspal), //int32_t
2610 parent_script_UID(other.parent_script_UID), //int32_t
2611 frozentile(other.frozentile), //int32_t
2612 frozencset(other.frozencset), //int32_t
2613 frozenclock(other.frozenclock), //int32_t
2614 isCore(other.isCore), //int32_t
2615 parentCore(other.parentCore), //int32_t
2616 script_UID(other.script_UID), //int32_t
2617 firesfx(other.firesfx), //int32_t
2618 //script(other.script), //int32_t
2619 //waitdraw(other.waitdraw), //int32_t
2620 weaponscript(other.weaponscript), //int32_t
2621 stickclk(other.stickclk), //int32_t
2622 hitdir(other.hitdir), //int32_t
2623 submerged(other.submerged), //int32_t
2624 ffcactivated(other.ffcactivated), //word
2625
2626 dialogue_str(other.dialogue_str), //int32_t
2627 editorflags(other.editorflags), //int32_t
2628 //drawflags(other.drawflags), //int32_t
2629 o_tile(other.o_tile), //int32_t
2630 frate(other.frate), //int32_t
2631 //tile(other.tile), //int32_t
2632 //scripttile(other.scripttile), //int32_t
2633 //scriptflip(other.scriptflip), //int32_t
2634 //do_animation(other.do_animation), //int32_t
2635 immortal(other.immortal), //bool
2636 noSlide(other.noSlide), //bool
2637 deathexstate(other.deathexstate), //int32_t
2638 flags(other.flags), //int32_t
2639 step(other.step), //int32_t
2640
2641 item_set(other.item_set), //int32_t
2642 grumble(other.grumble), //int32_t
2643 leader(other.leader), //int32_t
2644 itemguy(other.itemguy), //int32_t
2645 dying(other.dying), //int32_t
2646 scored(other.scored), //int32_t
2647 //canfreeze(other.canfreeze), //int32_t
2648 count_enemy(other.count_enemy), //int32_t
2649 mainguy(other.mainguy), //int32_t
2650 //dir(other.dir), //int32_t
2651
2652 //txsz(other.txsz), //int32_t
2653 //tysz(other.tysz), //int32_t
2654 //hxsz(other.hxsz), //int32_t
2655 //hysz(other.hysz), //int32_t
2656 //hzsz(other.hzsz), //int32_t
2657 //hxofs(other.hxofs), //int32_t
2658 //hxofs(other.hxofs), //int32_t
2659 //xofs(other.xofs), //int32_t
2660 //yofs(other.yofs), //int32_t
2661 //hzofs(other.hzofs), //int32_t
2662 //zofs(other.zofs), //int32_t
2663
2664 wpn(other.wpn), //int32_t
2665 SIZEflags(other.SIZEflags), //int32_t
2666 hashero(other.hashero)
2667
2668 {
2669
2670 //arrays
2671
2672 if(other.scrmem)
2673 {
2674 alloc_scriptmem();
2675 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2676
2677 scrmem->scriptData = other.scrmem->scriptData;
2678 }
2679 else scrmem = NULL;
2680 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2681 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2682
2683 for(int32_t i=0; i<edefLAST255; i++)
2684 defense[i]=other.defense[i];
2685 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2686 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2687
2688 if(new_script_uid)
2689 {
2690 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2691 }
2692 if(clear_parent_script_UID)
2693 {
2694 parent_script_UID = 0;
2695 }
2696 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2697 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2698
2699 for ( int32_t q = 0; q < 8; q++ )
2700 {
2701 initD[q] = other.initD[q];
2702 weap_initiald[q] = other.weap_initiald[q];
2703 }
2704 for ( int32_t q = 0; q < 2; q++ )
2705 {
2706 initA[q] = other.initA[q];
2707 weap_initiala[q] = other.weap_initiala[q];
2708 }
2709 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2710 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
2711 // al_trace("Enemy txsz:%i\n", txsz);
2712 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
2713 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
2714 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
2715 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
2716 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
2717 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
2718 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
2719 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
2720 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2721 {
2722 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
2723 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2724 }
2725
2726 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
2727
2728
2729
2730
2731 }
2732
2733
2734 598 int32_t enemy::getScriptUID() { return script_UID; }
2735 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
2736 48762 enemy::~enemy()
2737 48762 {
2738
2/4
✓ Branch 0 taken 48762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48762 times.
✗ Branch 3 not taken.
48762 FFCore.deallocateAllArrays(SCRIPT_NPC, getUID());
2739
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 48758 times.
48762 if(hashero)
2740 {
2741
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
2742 4 hashero=false;
2743 4 }
2744 48762 }
2745
2746
2747 bool enemy::is_move_paused()
2748 {
2749 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
2750 }
2751
2752 7765 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
2753 {
2754 7765 int32_t yg = (special==spw_floater)?8:0;
2755 7765 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
2756 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
2757
1/2
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
7765 if(input_x == -1000)
2758 input_x = dx;
2759
1/2
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
7765 if(input_y == -1000)
2760 input_y = dy;
2761
2762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
15530 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
2763
3/6
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7765 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7765 times.
7765 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
2764
2/4
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7765 times.
✗ Branch 3 not taken.
7765 || ((input_x+hxsz-1) >= (240+nb)) || ((input_y+hysz-1) >= (160+nb))))
2765 return true;
2766
2767
3/6
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7765 times.
✗ Branch 5 not taken.
7765 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
2768 {
2769 if(ispitfall(dx,dy))
2770 return true;
2771 }
2772
2773 7765 bool flying = false;
2774 7765 bool cansolid = false;
2775
1/2
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
7765 if(moveflags & FLAG_IGNORE_SOLIDITY)
2776 cansolid = true;
2777
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7765 switch(special)
2778 {
2779 case spw_clipbottomright:
2780 if(dy>=128 || dx>=208) return true;
2781 break;
2782 case spw_clipright:
2783 break; //if(input_x>=208) return true; break;
2784
2785 case spw_wizzrobe: // fall through
2786 case spw_floater: // Special case for fliers and wizzrobes - hack!
2787 {
2788 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
2789 {
2790 if(dy < 32-yg || dy >= 144) return true;
2791 if(dx < 32 || dx >= 224) return true;
2792 }
2793 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
2794 return true;
2795 cansolid = true;
2796 flying = true;
2797 }
2798 }
2799
2800 7765 dx &= ~7;
2801 7765 dy &= ~7;
2802
2803
3/6
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7765 times.
✗ Branch 5 not taken.
7765 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
2804
2805
4/8
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7765 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7765 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 7765 times.
7765 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
2806 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
2807 //_walkflag code
2808 mapscr *s1, *s2;
2809 7765 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
2810 7765 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
2811
2812 7765 int32_t cpos=(dx>>4)+(dy&0xF0);
2813
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
✓ Branch 2 taken 6784 times.
✓ Branch 3 taken 981 times.
7765 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
2814 7765 newcombo const& c = combobuf[ci];
2815 7765 newcombo const& c1 = combobuf[ci1];
2816 7765 newcombo const& c2 = combobuf[ci2];
2817
2818 7765 int32_t b=1;
2819
2/2
✓ Branch 0 taken 4122 times.
✓ Branch 1 taken 3643 times.
7765 if(dx&8) b<<=2;
2820
2/2
✓ Branch 0 taken 4667 times.
✓ Branch 1 taken 3098 times.
7765 if(dy&8) b<<=1;
2821
2822 #define iwtr(cmb, x, y, shallow) \
2823 (shallow \
2824 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
2825 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
2826 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
2827 7765 bool wtr = iwtr(ci, dx, dy, false);
2828
1/2
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
7765 bool shwtr = iwtr(ci, dx, dy, true);
2829 7765 bool pit = ispitfall(dx,dy);
2830
2831
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
✓ Branch 2 taken 7765 times.
✗ Branch 3 not taken.
7765 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
2832
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7765 times.
7765 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
2833 7765 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
2834 7765 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
2835 7765 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
2836
2837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
7765 if(!cansolid)
2838 {
2839 7765 int32_t cwalkflag = c.walk & 0xF;
2840
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7765 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7765 if (c.type == cBRIDGE && get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
2841
1/2
✓ Branch 0 taken 7765 times.
✗ Branch 1 not taken.
7765 if (s1)
2842 {
2843 if (c1.type == cBRIDGE)
2844 {
2845 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2846 {
2847 int efflag = (c1.walk & 0xF0)>>4;
2848 int newsolid = (c1.walk & 0xF);
2849 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2850 }
2851 else cwalkflag &= c1.walk;
2852 }
2853 else cwalkflag |= c1.walk & 0xF;
2854 }
2855
2/2
✓ Branch 0 taken 981 times.
✓ Branch 1 taken 6784 times.
7765 if (s2)
2856 {
2857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6784 times.
6784 if (c2.type == cBRIDGE)
2858 {
2859 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2860 {
2861 int efflag = (c2.walk & 0xF0)>>4;
2862 int newsolid = (c2.walk & 0xF);
2863 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2864 }
2865 else cwalkflag &= c2.walk;
2866 }
2867 6784 else cwalkflag |= c2.walk & 0xF;
2868 6784 }
2869
2/2
✓ Branch 0 taken 2533 times.
✓ Branch 1 taken 5232 times.
7765 if(cwalkflag & b)
2870 2533 return true;
2871 5232 }
2872
3/6
✓ Branch 0 taken 5232 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5232 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5232 times.
5232 if(needwtr || needshwtr || needpit)
2873 {
2874 bool ret = true;
2875 if (needwtr && wtr) ret = false;
2876 else if (needshwtr && shwtr) ret = false;
2877 else if (needpit && pit) ret = false;
2878 return ret;
2879 }
2880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5232 else if(wtr && !canwtr)
2881 return true;
2882
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5232 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5232 else if(pit && !canpit)
2883 return true;
2884
2885 5232 return false;
2886 7765 }
2887
2888 4277 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2889 {
2890
3/4
✓ Branch 0 taken 3251 times.
✓ Branch 1 taken 1026 times.
✓ Branch 2 taken 3251 times.
✗ Branch 3 not taken.
4277 if(!(dx || dy)) return true;
2891 4277 zfix bx = x+hxofs, by = y+hyofs; //left/top
2892 4277 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4277 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4277 if(!ign_sv && dy < 0) //check gravity
2894 {
2895 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2896 return false;
2897 }
2898
2899
2/4
✓ Branch 0 taken 4277 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4277 times.
4277 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
2900
2901
3/4
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 3251 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1026 times.
4277 if(dx && !dy)
2902 {
2903
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 694 times.
1026 if(dx < 0)
2904 {
2905
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 332 times.
332 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
2906 332 int mx = (bx+dx).getFloor();
2907
2/2
✓ Branch 0 taken 664 times.
✓ Branch 1 taken 332 times.
996 for(zfix ty = 0; by+ty < ry; ty += 8)
2908 {
2909
1/2
✓ Branch 0 taken 664 times.
✗ Branch 1 not taken.
664 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
2910 return false;
2911 664 }
2912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
2913 return false;
2914
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if(nosolid && collide_object(bx+dx,by,-dx,hysz,this))
2915 return false;
2916 332 }
2917 else
2918 {
2919 694 int mx = (rx+dx).getCeil();
2920 694 int lx = mx-hxsz+1;
2921
2/2
✓ Branch 0 taken 1388 times.
✓ Branch 1 taken 694 times.
2082 for(zfix ty = 0; by+ty < ry; ty += 8)
2922 {
2923
1/2
✓ Branch 0 taken 1388 times.
✗ Branch 1 not taken.
1388 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
2924 return false;
2925 1388 }
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
2927 return false;
2928
2/4
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 694 times.
✗ Branch 3 not taken.
694 if(nosolid && collide_object(bx+hxsz,by,dx,hysz,this))
2929 return false;
2930 }
2931 1026 }
2932
2/4
✓ Branch 0 taken 3251 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3251 times.
3251 else if(dy && !dx)
2933 {
2934
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 2621 times.
3251 if(dy < 0)
2935 {
2936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 special = (special==spw_clipbottomright)?spw_none:special;
2937 630 int my = (by+dy).getFloor();
2938
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 630 times.
1890 for(zfix tx = 0; bx+tx < rx; tx += 8)
2939 {
2940
1/2
✓ Branch 0 taken 1260 times.
✗ Branch 1 not taken.
1260 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
2941 return false;
2942 1260 }
2943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(scr_walkflag(rx, my, special, up, bx, my, kb))
2944 return false;
2945
2/4
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 630 times.
✗ Branch 3 not taken.
630 if(nosolid && collide_object(bx,by+dy,hxsz,-dy,this))
2946 return false;
2947 630 }
2948 else
2949 {
2950 2621 int my = (ry+dy).getCeil();
2951 2621 int ly = my-hysz+1;
2952
2/2
✓ Branch 0 taken 2709 times.
✓ Branch 1 taken 88 times.
2797 for(zfix tx = 0; bx+tx < rx; tx += 8)
2953 {
2954
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 2533 times.
2709 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
2955 2533 return false;
2956 176 }
2957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
2958 return false;
2959
2/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
88 if(nosolid && collide_object(bx,by+hysz,hxsz,dy,this))
2960 return false;
2961 }
2962 718 }
2963 else //! Untested, and currently unused.
2964 {
2965 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
2966 }
2967 1744 return true;
2968 4277 }
2969
2970 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
2971 {
2972 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
2973 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2974
2975 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
2976
2977 if(nosolid && collide_object(bx,by,hxsz,hysz,this))
2978 return false;
2979 for(zfix ty = 0; by+ty < ry; ty += 8)
2980 {
2981 for(zfix tx = 0; bx+tx < rx; tx += 8)
2982 {
2983 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
2984 return false;
2985 }
2986 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
2987 return false;
2988 }
2989 for(zfix tx = 0; bx+tx < rx; tx += 8)
2990 {
2991 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
2992 return false;
2993 }
2994 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
2995 return false;
2996 return true;
2997 }
2998
2999 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
3000 {
3001 auto oxsz = hxsz, oysz = hysz;
3002 if(nwid > -1) hxsz = nwid;
3003 if(nhei > -1) hysz = nhei;
3004 bool ret = scr_canplace(dx,dy,special,kb);
3005 hxsz = oxsz; hysz = oysz;
3006 return ret;
3007 }
3008
3009 1796 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
3010 {
3011 1796 bool ret = true;
3012
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1796 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1796 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
3013 dy = 0;
3014 1796 const int scl = 2;
3015
4/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 1919 times.
✓ Branch 2 taken 193 times.
✓ Branch 3 taken 1796 times.
1989 while(abs(dx) > scl || abs(dy) > scl)
3016 {
3017
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 136 times.
193 if(abs(dx) > abs(dy))
3018 {
3019 57 int32_t tdx = dx.sign() * scl;
3020
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
3021 57 dx -= tdx;
3022 else
3023 {
3024 if(earlyret) return false;
3025 dx = tdx;
3026 ret = false;
3027 }
3028 57 }
3029 else
3030 {
3031 136 int32_t tdy = dy.sign() * scl;
3032
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 62 times.
136 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
3033 74 dy -= tdy;
3034 else
3035 {
3036
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 if(earlyret) return false;
3037 62 dy = tdy;
3038 62 ret = false;
3039 }
3040 }
3041 }
3042
3043
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 1026 times.
1796 if(dx)
3044 {
3045
1/2
✓ Branch 0 taken 1026 times.
✗ Branch 1 not taken.
1026 if(scr_canmove(dx, 0, special, kb, ign_sv))
3046 1026 x += dx;
3047 else
3048 {
3049 if(earlyret) return false;
3050 ret = false;
3051 int xsign = dx.sign();
3052 while(scr_canmove(xsign, 0, special, kb, ign_sv))
3053 {
3054 x += xsign;
3055 dx -= xsign;
3056 }
3057 if(dx)
3058 {
3059 dx.doDecBound(0,-9999, 0,9999);
3060 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
3061 if(scr_canmove(val, 0, special, kb, ign_sv))
3062 {
3063 retval = val;
3064 return BSEARCH_CONTINUE_AWAY0;
3065 }
3066 else return BSEARCH_CONTINUE_TOWARD0;
3067 });
3068 x += dx;
3069 }
3070 }
3071 1026 }
3072
2/2
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 867 times.
1796 if(dy)
3073 {
3074
2/2
✓ Branch 0 taken 718 times.
✓ Branch 1 taken 149 times.
867 if(scr_canmove(0, dy, special, kb, ign_sv))
3075 718 y += dy;
3076 else
3077 {
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(earlyret) return false;
3079 149 ret = false;
3080 149 int ysign = dy.sign();
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 while(scr_canmove(0, ysign, special, kb, ign_sv))
3082 {
3083 y += ysign;
3084 dy -= ysign;
3085 }
3086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if(dy)
3087 {
3088 149 dy.doDecBound(0,-9999, 0,9999);
3089
3/6
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
2384 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
3090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2235 times.
2235 if(scr_canmove(0, val, special, kb, ign_sv))
3091 {
3092 retval = val;
3093 return BSEARCH_CONTINUE_AWAY0;
3094 }
3095 2235 else return BSEARCH_CONTINUE_TOWARD0;
3096 2235 });
3097 149 y += dy;
3098 149 }
3099 }
3100 867 }
3101 1796 return ret;
3102 1796 }
3103
3104 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
3105 {
3106 zfix diagrate = zslongToFix(7071);
3107 switch(NORMAL_DIR(dir))
3108 {
3109 case up:
3110 return movexy(0, -px, special, kb, false, earlyret);
3111 case down:
3112 return movexy(0, px, special, kb, false, earlyret);
3113 case left:
3114 return movexy(-px, 0, special, kb, false, earlyret);
3115 case right:
3116 return movexy(px, 0, special, kb, false, earlyret);
3117 case r_up:
3118 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
3119 case r_down:
3120 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
3121 case l_up:
3122 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
3123 case l_down:
3124 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
3125 }
3126 return false;
3127 }
3128
3129 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
3130 {
3131 double v = degrees.getFloat() * PI / 180.0;
3132 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
3133 return movexy(dx, dy, special, kb, false, earlyret);
3134 }
3135
3136 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
3137 {
3138 zfix tx = x, ty = y;
3139 bool ret = movexy(dx, dy, special, kb, false, true);
3140 x = tx;
3141 y = ty;
3142 return ret;
3143 }
3144 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3145 {
3146 zfix tx = x, ty = y;
3147 bool ret = moveDir(dir, px, special, kb, true);
3148 x = tx;
3149 y = ty;
3150 return ret;
3151 }
3152 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3153 {
3154 zfix tx = x, ty = y;
3155 bool ret = moveAtAngle(degrees, px, special, kb, true);
3156 x = tx;
3157 y = ty;
3158 return ret;
3159 }
3160
3161 // Handle pitfalls
3162 19304031 bool enemy::do_falling(int32_t index)
3163 {
3164
2/2
✓ Branch 0 taken 19303889 times.
✓ Branch 1 taken 142 times.
19304031 if(fallclk > 0)
3165 {
3166
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
3167
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
3168 {
3169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
3170 ++fallclk; //force another frame of falling.... forever.
3171
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
3172 {
3173
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
3174 never_return(index);
3175
3176
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
3177 kill_em_all();
3178
3179 //leave_item(); //Don't drop items in pits!
3180 2 stop_bgsfx(index);
3181 2 return true;
3182 }
3183 else
3184 {
3185 2 try_death(true); //Force death
3186 2 ++fallclk; //force another frame of falling
3187 }
3188 2 }
3189
3190 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
3191 140 cs = spr.csets & 0xF;
3192
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
3193
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
3194 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
3195
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
3196 140 }
3197 19304029 return false;
3198 19304031 }
3199
3200 // Handle drowning in water
3201 19303889 bool enemy::do_drowning(int32_t index)
3202 {
3203
1/2
✓ Branch 0 taken 19303889 times.
✗ Branch 1 not taken.
19303889 if(drownclk > 0)
3204 {
3205 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
3206 //!TODO: Drown SFX
3207 if(!--drownclk)
3208 {
3209 if(immortal) //Keep alive forever
3210 ++drownclk; //force another frame of falling.... forever.
3211 else if(dying) //Give 1 frame for script revival
3212 {
3213 if(flags&guy_neverret)
3214 never_return(index);
3215
3216 if(leader)
3217 kill_em_all();
3218
3219 //leave_item(); //Don't drop items in pits!
3220 stop_bgsfx(index);
3221 return true;
3222 }
3223 else
3224 {
3225 try_death(true); //Force death
3226 ++drownclk; //force another frame of falling
3227 }
3228 }
3229
3230 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
3231 {
3232 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
3233 cs = spr.csets & 0xF;
3234 int32_t fr = spr.frames ? spr.frames : 1;
3235 int32_t spd = spr.speed ? spr.speed : 1;
3236 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3237 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3238 }
3239 else
3240 {
3241 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
3242 cs = spr.csets & 0xF;
3243 int32_t fr = spr.frames ? spr.frames : 1;
3244 int32_t spd = spr.speed ? spr.speed : 1;
3245 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3246 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3247 }
3248 }
3249 19303889 return false;
3250 19303889 }
3251
3252 // Supplemental animation code that all derived classes should call
3253 // as a return value for animate().
3254 // Handles the death animation and returns true when enemy is finished.
3255 19664713 bool enemy::Dead(int32_t index)
3256 {
3257
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 19662884 times.
19664713 if(immortal)
3258 {
3259 1829 dying = false;
3260 1829 return false;
3261 }
3262
2/2
✓ Branch 0 taken 394065 times.
✓ Branch 1 taken 19268819 times.
19662884 if(dying)
3263 {
3264
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 394064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
394065 if(deathexstate > -1 && deathexstate < 32)
3265 {
3266 1 setxmapflag(1<<deathexstate);
3267 1 deathexstate = -1;
3268 1 }
3269 394065 --clk2;
3270
3271
4/4
✓ Branch 0 taken 389370 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 19765 times.
✓ Branch 3 taken 894 times.
394065 if((get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
3272
2/2
✓ Branch 0 taken 20659 times.
✓ Branch 1 taken 368711 times.
389370 && hp>-1000) // not killed by ringleader
3273 19765 death_sfx();
3274
3275
2/2
✓ Branch 0 taken 373188 times.
✓ Branch 1 taken 20877 times.
394065 if(clk2==0)
3276 {
3277
2/2
✓ Branch 0 taken 20479 times.
✓ Branch 1 taken 398 times.
20877 if(flags&guy_neverret)
3278 398 never_return(index);
3279
3280
2/2
✓ Branch 0 taken 20824 times.
✓ Branch 1 taken 53 times.
20877 if(leader)
3281 53 kill_em_all();
3282
3283 20877 leave_item();
3284 20877 }
3285
3286 394065 stop_bgsfx(index);
3287 394065 return (clk2==0);
3288 }
3289
3290 19268819 return false;
3291 19664713 }
3292
3293 // Basic animation code that all derived classes should call.
3294 // The one with an index is the one that is called by
3295 // the guys sprite list; index is the enemy's index in the list.
3296 20262121 bool enemy::animate(int32_t index)
3297 {
3298
2/2
✓ Branch 0 taken 1779593 times.
✓ Branch 1 taken 18482528 times.
20262121 if(sclk <= 0) hitdir = -1;
3299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18573409 times.
20262121 if(switch_hooked)
3300 {
3301 if(get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT))
3302 {
3303 //Run its script
3304 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
3305 {
3306 return 0; //Avoid NULLPO if this object deleted itself
3307 }
3308 }
3309 return false;
3310 }
3311
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 18573407 times.
18573409 if(do_falling(index)) return true;
3312
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 18573267 times.
18573407 else if(fallclk)
3313 {
3314 //clks
3315
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
3316 60 --hclk;
3317
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
3318 --stunclk;
3319
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
3320 --frozenclock;
3321
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
3322 {
3323 Hero.setX(x);
3324 Hero.setY(y);
3325 Hero.fallCombo = fallCombo;
3326 Hero.fallclk = fallclk;
3327 hashero = false; //Let Hero go if falling
3328 }
3329 140 run_script(MODE_NORMAL);
3330 140 return false;
3331 }
3332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18573267 times.
18573267 if(do_drowning(index)) return true;
3333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18573267 times.
18573267 else if(drownclk)
3334 {
3335 //clks
3336 if(hclk>0)
3337 --hclk;
3338 if(stunclk>0)
3339 --stunclk;
3340 if ( frozenclock > 0 )
3341 --frozenclock;
3342 if(hashero)
3343 {
3344 Hero.setX(x);
3345 Hero.setY(y);
3346 Hero.drownclk = drownclk;
3347 hashero = false; //Let Hero go if falling
3348 }
3349 run_script(MODE_NORMAL);
3350 return false;
3351 }
3352 18573267 int32_t nx = real_x(x);
3353 18573267 int32_t ny = real_y(y);
3354
3355
4/4
✓ Branch 0 taken 14190401 times.
✓ Branch 1 taken 4382866 times.
✓ Branch 2 taken 3599561 times.
✓ Branch 3 taken 15004644 times.
18573267 if(ox!=nx || oy!=ny)
3356 {
3357 7982427 posframe=(posframe+1)%(get_bit(quest_rules,qr_NEWENEMYTILES)?4:2);
3358 7982427 }
3359
3360 22987071 ox = nx;
3361 22987071 oy = ny;
3362
3363 // Maybe they fell off the bottom in sideview, or were moved by a script.
3364
3365 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
3366
2/2
✓ Branch 0 taken 3685011 times.
✓ Branch 1 taken 19302060 times.
22987071 if ( immortal )
3367 {
3368 //skip, as it can go out of bounds, from immortality
3369 3685011 }
3370
2/6
✓ Branch 0 taken 19302060 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19302060 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
19302060 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_bit(quest_rules, qr_OUTOFBOUNDSENEMIES)) != (editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
3371 {
3372 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
3373 }
3374
9/10
✓ Branch 0 taken 18892367 times.
✓ Branch 1 taken 409693 times.
✓ Branch 2 taken 19301731 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 19296780 times.
✓ Branch 5 taken 4951 times.
✓ Branch 6 taken 19296780 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 19296744 times.
19302060 else if ( (OUTOFBOUNDS) )
3375 {
3376 5316 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
3377 5316 }
3378 //fall down
3379
6/6
✓ Branch 0 taken 12582702 times.
✓ Branch 1 taken 10404369 times.
✓ Branch 2 taken 6562225 times.
✓ Branch 3 taken 16424846 times.
✓ Branch 4 taken 300716 times.
✓ Branch 5 taken 6261509 times.
22987071 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
3380 {
3381
2/2
✓ Branch 0 taken 316274 times.
✓ Branch 1 taken 5945235 times.
6261509 if(isSideViewGravity())
3382 {
3383
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 12700 times.
316274 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
3384 {
3385
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
3386 {
3387 127235 bool willHitSVPlatform = false;
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hxsz:16;
3389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hysz:16;
3390
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
3391 {
3392
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
3393 {
3394 willHitSVPlatform = true;
3395 break;
3396 }
3397 127235 }
3398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
3399 {
3400 y+=fall/100;
3401 //y-=int32_t(y)%16; //Fix to top of SV Ladder
3402 do_fix(y, 16); //Fix to top of SV Ladder
3403 fall = 0;
3404 }
3405 else
3406 {
3407 127235 y+=fall/100;
3408
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
3409 109427 fall += (zinit.gravity2/100);
3410 }
3411 127235 }
3412 else
3413 {
3414
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
3415 {
3416 //y-=(int32_t)y%8; // Fix position
3417 267 do_fix(y, 8); //Fix position
3418 267 }
3419
3420 176339 fall = 0;
3421 }
3422 303574 }
3423 else
3424 {
3425
2/2
✓ Branch 0 taken 11361 times.
✓ Branch 1 taken 1339 times.
12700 if(isOnSideviewPlatform())
3426 11361 fall = 0;
3427 else
3428 {
3429 1339 zfix fall_amnt = fall/100;
3430 1339 bool hit = false;
3431
2/2
✓ Branch 0 taken 1276 times.
✓ Branch 1 taken 1502 times.
2778 while(fall_amnt >= 1)
3432 {
3433 1502 --fall_amnt;
3434 1502 ++y;
3435
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 63 times.
1502 if(isOnSideviewPlatform())
3436 {
3437 63 y = y.getInt();
3438 63 fall_amnt = 0;
3439 63 hit = true;
3440 63 break;
3441 }
3442 }
3443
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1198 times.
1339 if(fall_amnt > 0)
3444 1198 y += fall_amnt;
3445
1/2
✓ Branch 0 taken 1339 times.
✗ Branch 1 not taken.
1339 if(fall_amnt < 0)
3446 {
3447 if(!movexy(0,fall_amnt,spw_none))
3448 hit = true;
3449 }
3450
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 1276 times.
1339 if(hit)
3451 63 fall = 0;
3452
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 1088 times.
1276 else if(fall <= (int32_t)zinit.terminalv)
3453 1088 fall += (zinit.gravity2/100);
3454 }
3455 }
3456 316274 }
3457 else
3458 {
3459
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945235 times.
5945235 if (!(moveflags & FLAG_NO_FAKE_Z))
3460 {
3461
2/2
✓ Branch 0 taken 3009463 times.
✓ Branch 1 taken 2935772 times.
5945235 if(fakefall!=0)
3462 2935772 fakez-=(fakefall/100);
3463
3464
2/2
✓ Branch 0 taken 2935772 times.
✓ Branch 1 taken 3009463 times.
5945235 if(fakez<0)
3465 2935772 fakez = fakefall = 0;
3466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3009463 times.
3009463 else if(fakefall <= (int32_t)zinit.terminalv)
3467 3009463 fakefall += (zinit.gravity2/100);
3468
3469
5/6
✓ Branch 0 taken 5945235 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3009463 times.
✓ Branch 3 taken 2935772 times.
✓ Branch 4 taken 2942942 times.
✓ Branch 5 taken 66521 times.
5945235 if (fakez<=0 && fakefall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
3470 5945235 }
3471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5945235 times.
5945235 if (!(moveflags & FLAG_NO_REAL_Z))
3472 {
3473
2/2
✓ Branch 0 taken 3057088 times.
✓ Branch 1 taken 2888147 times.
5945235 if(fall!=0)
3474 2888147 z-=(fall/100);
3475
3476
2/2
✓ Branch 0 taken 2882323 times.
✓ Branch 1 taken 3062912 times.
5945235 if(z<0)
3477 2882323 z = fall = 0;
3478
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3058268 times.
3062912 else if(fall <= (int32_t)zinit.terminalv)
3479 3058268 fall += (zinit.gravity2/100);
3480
3481
6/6
✓ Branch 0 taken 5939314 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3056991 times.
✓ Branch 3 taken 2882323 times.
✓ Branch 4 taken 2990470 times.
✓ Branch 5 taken 66521 times.
5945235 if (z<=0 && fall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
3482 5945235 }
3483
3484 }
3485 6261509 }
3486
4/4
✓ Branch 0 taken 18894196 times.
✓ Branch 1 taken 4092875 times.
✓ Branch 2 taken 9988631 times.
✓ Branch 3 taken 16572011 times.
22987071 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
3487 {
3488
8/10
✓ Branch 0 taken 5531926 times.
✓ Branch 1 taken 11040085 times.
✓ Branch 2 taken 5524941 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 5524941 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5531926 times.
✓ Branch 8 taken 5524941 times.
✓ Branch 9 taken 5524941 times.
16572011 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3489 {
3490 5524941 fallCombo = check_pits();
3491 5524941 }
3492 27621893 }
3493
3/4
✓ Branch 0 taken 18894196 times.
✓ Branch 1 taken 409693 times.
✓ Branch 2 taken 18894196 times.
✗ Branch 3 not taken.
19623229 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
3494 {
3495 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3496 {
3497 drownCombo = check_water();
3498 }
3499 }
3500
3501 19303889 runKnockback(); //scripted knockback handling
3502
3503 // clk is incremented here
3504
2/2
✓ Branch 0 taken 18271518 times.
✓ Branch 1 taken 1032371 times.
19303889 if(++clk >= frate)
3505 1032371 clk=0;
3506
3507 // hit and death handling
3508
2/2
✓ Branch 0 taken 18656379 times.
✓ Branch 1 taken 647510 times.
19303889 if(hclk>0)
3509 647510 --hclk;
3510
3511
2/2
✓ Branch 0 taken 18923721 times.
✓ Branch 1 taken 380168 times.
19303889 if(stunclk>0)
3512 380168 --stunclk;
3513
1/2
✓ Branch 0 taken 19303889 times.
✗ Branch 1 not taken.
19303889 if ( frozenclock > 0 )
3514 --frozenclock;
3515
3516
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 19296887 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
19303889 if(ceiling && z <= 0 && fakez <= 0)
3517 55 ceiling = false;
3518
3519 19303889 try_death();
3520
3521 19303889 scored=false;
3522
3523 19303889 ++c_clk;
3524
3525 //Run its script
3526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19303889 times.
19303889 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
3527 {
3528 return 0; //Avoid NULLPO if this object deleted itself
3529 }
3530
3531 // returns true when enemy is defeated
3532 19303889 return Dead(index);
3533 19304031 }
3534
3535 19701572 bool enemy::setSolid(bool set)
3536 {
3537
1/2
✓ Branch 0 taken 19701572 times.
✗ Branch 1 not taken.
19701572 bool actual = set && !isSubmerged();
3538 19701572 bool ret = solid_object::setSolid(actual);
3539 19701572 solid = set;
3540 19701572 return ret;
3541 }
3542 void enemy::doContactDamage(int32_t hdir)
3543 {
3544 Hero.hithero(guys.find(this), hdir);
3545 }
3546
3547 42798 void enemy::solid_push(solid_object *obj)
3548 {
3549
1/2
✓ Branch 0 taken 42798 times.
✗ Branch 1 not taken.
42798 if(obj == this) return; //can't push self
3550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42798 times.
42798 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
3551 42798 zfix dx, dy;
3552 42798 int32_t hdir = -1;
3553 42798 solid_push_int(obj,dx,dy,hdir);
3554
3555
4/4
✓ Branch 0 taken 41829 times.
✓ Branch 1 taken 969 times.
✓ Branch 2 taken 41195 times.
✓ Branch 3 taken 634 times.
42798 if(!dx && !dy) return;
3556
3557 1603 bool t = obj->getTempNonsolid();
3558 1603 obj->setTempNonsolid(true);
3559
3560 1603 int32_t ydir = dy > 0 ? down : up;
3561 1603 int32_t xdir = dx > 0 ? right : left;
3562
3563 1603 auto special = isflier(id) ? spw_floater : spw_none;
3564
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 87 times.
1603 if(!movexy(dx,dy,special,true,true))
3565 {
3566 //Crushed?
3567 87 }
3568
3569 1603 obj->setTempNonsolid(t);
3570 42798 }
3571 42798 bool enemy::is_unpushable() const
3572 {
3573 42798 return isSubmerged();
3574 }
3575 42798 bool enemy::sideview_mode() const
3576 {
3577
3/4
✓ Branch 0 taken 13600 times.
✓ Branch 1 taken 29198 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13600 times.
42798 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
3578 }
3579
3580 2447 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
3581 {
3582 2447 int32_t yg = (special==spw_floater)?8:0;
3583 2447 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3584
3585
8/10
✓ Branch 0 taken 1858 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 533 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1860 times.
✓ Branch 9 taken 2449 times.
2447 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3586 3718 return true;
3587
3588 2449 bool isInDungeon = isdungeon();
3589
3/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 2334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
2449 if(isInDungeon || special==spw_wizzrobe)
3590 {
3591
7/8
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 1863 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 472 times.
✓ Branch 5 taken 1396 times.
✓ Branch 6 taken 472 times.
✗ Branch 7 not taken.
2334 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
3592 938 return true;
3593
3594
7/8
✓ Branch 0 taken 465 times.
✓ Branch 1 taken 931 times.
✓ Branch 2 taken 466 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 466 times.
✓ Branch 5 taken 466 times.
✓ Branch 6 taken 466 times.
✗ Branch 7 not taken.
1396 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
3595
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
932 if(special!=spw_door) // walk in door way
3596 return true;
3597 466 }
3598
3599
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
581 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
3600 {
3601
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39 times.
78 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3602
2/4
✓ Branch 0 taken 39 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
39 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3603 return true;
3604 39 }
3605
3606
1/4
✓ Branch 0 taken 581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
581 switch(special)
3607 {
3608 case spw_clipbottomright:
3609 if(dy>=128 || dx>=208) return true;
3610 break;
3611 case spw_clipright:
3612 break; //if(x>=208) return true; break;
3613
3614 case spw_wizzrobe: // fall through
3615 case spw_floater: // Special case for fliers and wizzrobes - hack!
3616 {
3617
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 466 times.
581 if(isInDungeon)
3618 {
3619
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(dy < 32-yg || dy >= 144) return true;
3620
2/4
✓ Branch 0 taken 466 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466 times.
466 if(dx < 32 || dx >= 224) return true;
3621 466 }
3622 581 return false;
3623 }
3624 }
3625
3626 dx&=(special==spw_halfstep)?(~7):(~15);
3627 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3628
3629 if(special==spw_water)
3630 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3631
3632 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3633 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
3634 589 }
3635
3636 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
3637 {
3638 5149 bool kb = false;
3639 5149 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3640
3641
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5041 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
3642 return true;
3643
3644
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
3645 {
3646
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
3647 return true;
3648
3649
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
3650 return true;
3651 715 }
3652
3653
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
3654 {
3655
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3656
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3657 return true;
3658 5149 }
3659
3660
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3661 {
3662
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3664 }
3665 else
3666 {
3667 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3668 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3669 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3670 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3671 }
3672 5149 }
3673
3674 18583809 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
3675 {
3676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18583809 times.
18583809 if(moveflags & FLAG_USE_NEW_MOVEMENT)
3677 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
3678 18583809 int32_t yg = (special==spw_floater)?8:0;
3679 18583809 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3680
2/2
✓ Branch 0 taken 1808228 times.
✓ Branch 1 taken 16775581 times.
18583809 switch(dir)
3681 {
3682 case l_down:
3683 case r_down:
3684 case down:
3685 case 11: //r_down
3686 case 12: //down
3687 case 13: //l_down
3688 {
3689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1808228 times.
1808228 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3690 {
3691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1808228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1808228 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
3692 {
3693 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3694 dy += zc_max(hysz-16,0);
3695 }
3696 1808228 }
3697 1808228 break;
3698 }
3699 }
3700
2/2
✓ Branch 0 taken 1820189 times.
✓ Branch 1 taken 16763620 times.
18583809 switch(dir)
3701 {
3702 case r_up:
3703 case r_down:
3704 case right:
3705 case 9: //r_up
3706 case 10: //right
3707 case 11: //r_down
3708 {
3709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1820189 times.
1820189 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3710 {
3711
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1820189 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1820189 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
3712 {
3713 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3714 dx += zc_max(hxsz-16,0);
3715 }
3716 1820189 }
3717 1820189 break;
3718 }
3719 }
3720 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
3721
3722
10/10
✓ Branch 0 taken 13695577 times.
✓ Branch 1 taken 4888232 times.
✓ Branch 2 taken 1105531 times.
✓ Branch 3 taken 3782701 times.
✓ Branch 4 taken 4878164 times.
✓ Branch 5 taken 10068 times.
✓ Branch 6 taken 4866673 times.
✓ Branch 7 taken 11491 times.
✓ Branch 8 taken 13719909 times.
✓ Branch 9 taken 18586582 times.
18583809 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3723 27437045 return true;
3724
3725 18586582 bool isInDungeon = isdungeon();
3726
4/4
✓ Branch 0 taken 1186543 times.
✓ Branch 1 taken 17400039 times.
✓ Branch 2 taken 611 times.
✓ Branch 3 taken 1185932 times.
18586582 if(isInDungeon || special==spw_wizzrobe)
3727 {
3728
8/8
✓ Branch 0 taken 3590853 times.
✓ Branch 1 taken 13809797 times.
✓ Branch 2 taken 3461474 times.
✓ Branch 3 taken 129379 times.
✓ Branch 4 taken 3550050 times.
✓ Branch 5 taken 10389126 times.
✓ Branch 6 taken 3550036 times.
✓ Branch 7 taken 14 times.
17400650 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
3729 7011510 return true;
3730
3731
8/8
✓ Branch 0 taken 3502310 times.
✓ Branch 1 taken 6886830 times.
✓ Branch 2 taken 3403820 times.
✓ Branch 3 taken 98490 times.
✓ Branch 4 taken 3470454 times.
✓ Branch 5 taken 3514866 times.
✓ Branch 6 taken 3470451 times.
✓ Branch 7 taken 3 times.
10389140 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
3732
2/2
✓ Branch 0 taken 66592 times.
✓ Branch 1 taken 39 times.
6874271 if(special!=spw_door) // walk in door way
3733 66592 return true;
3734 3514908 }
3735
3736
6/6
✓ Branch 0 taken 1886290 times.
✓ Branch 1 taken 2814550 times.
✓ Branch 2 taken 426366 times.
✓ Branch 3 taken 1459924 times.
✓ Branch 4 taken 34248 times.
✓ Branch 5 taken 392118 times.
4700840 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
3737 {
3738
3/4
✓ Branch 0 taken 1852035 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1852035 times.
3704077 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3739
2/4
✓ Branch 0 taken 1852035 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1852035 times.
✗ Branch 3 not taken.
1852035 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3740 7 return true;
3741 1852035 }
3742
3743
4/4
✓ Branch 0 taken 3744867 times.
✓ Branch 1 taken 952464 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3457 times.
4700833 switch(special)
3744 {
3745 case spw_clipbottomright:
3746
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
3747 45 break;
3748 case spw_clipright:
3749 3457 break; //if(input_x>=208) return true; break;
3750
3751 case spw_wizzrobe: // fall through
3752 case spw_floater: // Special case for fliers and wizzrobes - hack!
3753 {
3754
2/2
✓ Branch 0 taken 760029 times.
✓ Branch 1 taken 2984838 times.
3744867 if(isInDungeon)
3755 {
3756
3/4
✓ Branch 0 taken 2984827 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2984827 times.
2984838 if(dy < 32-yg || dy >= 144) return true;
3757
3/4
✓ Branch 0 taken 2983993 times.
✓ Branch 1 taken 834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2983993 times.
2984827 if(dx < 32 || dx >= 224) return true;
3758 2983993 }
3759 3744022 return false;
3760 }
3761 }
3762
3763 955966 dx&=(special==spw_halfstep)?(~7):(~15);
3764
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 731937 times.
955966 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3765
3766
2/2
✓ Branch 0 taken 109935 times.
✓ Branch 1 taken 846031 times.
955966 if(special==spw_water)
3767
2/2
✓ Branch 0 taken 6433 times.
✓ Branch 1 taken 103502 times.
109935 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3768
3769
2/2
✓ Branch 0 taken 841987 times.
✓ Branch 1 taken 4044 times.
846031 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3770 {
3771
4/4
✓ Branch 0 taken 637824 times.
✓ Branch 1 taken 204163 times.
✓ Branch 2 taken 632598 times.
✓ Branch 3 taken 5226 times.
1474585 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3772
2/2
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 629944 times.
632598 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3773 }
3774 else
3775 {
3776
4/4
✓ Branch 0 taken 3147 times.
✓ Branch 1 taken 897 times.
✓ Branch 2 taken 3122 times.
✓ Branch 3 taken 25 times.
7166 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3777
4/4
✓ Branch 0 taken 2980 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 2965 times.
✓ Branch 3 taken 15 times.
3122 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3778
3/4
✓ Branch 0 taken 2884 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 2884 times.
✗ Branch 3 not taken.
2965 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3779
1/2
✓ Branch 0 taken 2884 times.
✗ Branch 1 not taken.
2884 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3780 }
3781 4901885 }
3782
3783 405278 bool enemy::isOnSideviewPlatform()
3784 {
3785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405278 times.
405278 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
3786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405278 times.
405278 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
3787
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 394972 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
405278 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
3788
2/2
✓ Branch 0 taken 1545 times.
✓ Branch 1 taken 403522 times.
405067 if(check_slope(x, y+1, usewid, usehei)) return true;
3789
2/2
✓ Branch 0 taken 403522 times.
✓ Branch 1 taken 171814 times.
575336 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
3790 {
3791
2/2
✓ Branch 0 taken 171814 times.
✓ Branch 1 taken 231708 times.
403522 if(_walkflag(nx,y+usehei,1)) return true;
3792
3/4
✓ Branch 0 taken 171814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124010 times.
✓ Branch 3 taken 47804 times.
171814 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
3793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47804 times.
47804 if(checkSVLadderPlatform(nx,y+usehei)) return true;
3794 47804 }
3795 171814 return false;
3796 405278 }
3797
3798 // Stops playing the given sound only if there are no enemies left to play it
3799 395827 void enemy::stop_bgsfx(int32_t index)
3800 {
3801
2/2
✓ Branch 0 taken 386307 times.
✓ Branch 1 taken 9520 times.
395827 if(bgsfx<=0)
3802 386307 return;
3803
3804 // Look for other enemies with the same bgsfx
3805
2/2
✓ Branch 0 taken 38890 times.
✓ Branch 1 taken 5578 times.
44468 for(int32_t i=0; i<guys.Count(); i++)
3806 {
3807
4/4
✓ Branch 0 taken 32095 times.
✓ Branch 1 taken 6795 times.
✓ Branch 2 taken 3942 times.
✓ Branch 3 taken 28153 times.
38890 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
3808 3942 return;
3809 34948 }
3810
3811 5578 stop_sfx(bgsfx);
3812 395827 }
3813
3814
3815 // to allow for different sfx on defeating enemy
3816 20002 void enemy::death_sfx()
3817 {
3818
1/2
✓ Branch 0 taken 20002 times.
✗ Branch 1 not taken.
20002 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
3819 20002 }
3820
3821 void enemy::move(zfix dx,zfix dy)
3822 {
3823 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3824 {
3825 switch(family)
3826 {
3827 case eeFIRE:
3828 case eeOTHER:
3829 return;
3830 default: break;
3831 }
3832 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3833 }
3834 */
3835 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
3836 {
3837 x+=dx;
3838 y+=dy;
3839 }
3840 }
3841
3842 9596355 void enemy::move(zfix s)
3843 {
3844 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3845 {
3846 switch(family)
3847 {
3848 case eeFIRE:
3849 case eeOTHER:
3850 return;
3851 default: break;
3852 }
3853 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3854 }*/
3855
9/10
✓ Branch 0 taken 9596316 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 87408 times.
✓ Branch 3 taken 9508908 times.
✓ Branch 4 taken 41759 times.
✓ Branch 5 taken 45649 times.
✓ Branch 6 taken 1890 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 1890 times.
✗ Branch 9 not taken.
9596355 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
3856 {
3857 9594426 sprite::move(s);
3858 9594426 }
3859 9596355 }
3860
3861 21044 void enemy::leave_item()
3862 {
3863 21044 int32_t drop_item = select_dropitem(item_set, x, y);
3864 21044 int32_t thedropset = item_set;
3865
3866 21044 std::vector<int32_t> &ev = FFCore.eventData;
3867 21044 ev.clear();
3868 21044 ev.push_back(getUID());
3869 21044 ev.push_back(drop_item*10000);
3870 21044 ev.push_back(thedropset*10000);
3871
3872 21044 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
3873 21044 drop_item = vbound(ev[1] / 10000,-2,255);
3874 21044 thedropset = ev[2] / 10000;
3875 21044 ev.clear();
3876
1/2
✓ Branch 0 taken 21044 times.
✗ Branch 1 not taken.
21044 if(drop_item == -2)
3877 {
3878 drop_item = select_dropitem(thedropset,x,y);
3879 }
3880
3881
6/6
✓ Branch 0 taken 8283 times.
✓ Branch 1 taken 12761 times.
✓ Branch 2 taken 414 times.
✓ Branch 3 taken 7869 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 366 times.
21044 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
3882 {
3883 item* itm;
3884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8235 times.
8235 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
3885 {
3886 itm = (new item(x+hxofs+(hxsz/2)-8,y+hyofs+(hysz/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3887 }
3888 else
3889 {
3890
8/14
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7762 times.
✓ Branch 2 taken 473 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 473 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 473 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 473 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 473 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 473 times.
✗ Branch 13 not taken.
8235 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3891
4/8
✓ Branch 0 taken 7762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7762 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7762 times.
✗ Branch 7 not taken.
7762 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3892 }
3893 8235 itm->from_dropset = thedropset;
3894 8235 items.add(itm);
3895
3896 8235 ev.push_back(getUID());
3897 8235 ev.push_back(itm->getUID());
3898
3899 8235 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
3900 8235 ev.clear();
3901 8235 }
3902 21044 }
3903
3904 // auomatically kill off enemy (for rooms with ringleaders)
3905 293 void enemy::kickbucket()
3906 {
3907
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 25 times.
293 if(!superman)
3908 268 hp=-1000; // don't call death_sfx()
3909 293 }
3910
3911 42798 bool enemy::isSubmerged() const
3912 {
3913 42798 return submerged;
3914 //!TODO SOLIDPUSH more things like teleporting wizzrobes
3915 }
3916
3917 17356 void enemy::FireBreath(bool seekhero)
3918 {
3919
1/2
✓ Branch 0 taken 17356 times.
✗ Branch 1 not taken.
17356 if(wpn==wNone)
3920 return;
3921
3922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17356 times.
17356 if(wpn==ewFireTrail)
3923 {
3924 dmisc1 = e1tEACHTILE;
3925 FireWeapon();
3926 return;
3927 }
3928
3929 17356 float fire_angle=0.0;
3930 17356 int32_t wx=0, wy=0, wdir=dir;
3931
3932
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 if(!seekhero)
3933 {
3934
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
3935 {
3936 case down:
3937 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
3938 3038 wx=x;
3939 3038 wy=y+8;
3940 3038 break;
3941
3942 case -1:
3943 case up:
3944 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
3945 3271 wx=x;
3946 3271 wy=y-8;
3947 3271 break;
3948
3949 case left:
3950 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
3951 5264 wx=x-8;
3952 5264 wy=y;
3953 5264 break;
3954
3955 case right:
3956 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
3957 4131 wx=x+8;
3958 4131 wy=y;
3959 4131 break;
3960 }
3961
3962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
3963 {
3964
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
3965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
3966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
3967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
3968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
3969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
3970
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
3971
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
3972 15704 }
3973 15704 }
3974 else
3975 {
3976 1652 wx = x;
3977 1652 wy = y;
3978 }
3979
3980
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
3981 17356 sfx(wpnsfx(wpn),pan(int32_t(x)));
3982
3983 17356 int32_t i=Ewpns.Count()-1;
3984 17356 weapon *ew = (weapon*)(Ewpns.spr(i));
3985 17356 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
3986
3987
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1652 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17356 if(!seekhero && (zc_oldrand()&4))
3988 {
3989 7874 ew->angular=true;
3990 7874 ew->angle=fire_angle;
3991 7874 }
3992
3993
4/4
✓ Branch 0 taken 17299 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 16982 times.
17356 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
3994 {
3995 16982 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
3996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16982 times.
16982 if ( ew->do_animation ) ew->tile+=ew->aframe;
3997 16982 }
3998
3999
2/2
✓ Branch 0 taken 17356 times.
✓ Branch 1 taken 542966 times.
560322 for(int32_t j=Ewpns.Count()-1; j>0; j--)
4000 {
4001 542966 Ewpns.swap(j,j-1);
4002 542966 }
4003 17356 }
4004
4005 25747 void enemy::FireWeapon()
4006 {
4007 /*
4008 * Type:
4009 * 0x01: Boss fireball
4010 * 0x02: Seeks Hero
4011 * 0x04: Fast projectile
4012 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
4013 */
4014
4015
2/2
✓ Branch 0 taken 25737 times.
✓ Branch 1 taken 10 times.
25747 if (wpn < 1) return;
4016
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 25737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
25737 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
4017 return;
4018
4019
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25737 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
25737 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
4020 dmisc1 = e1tEACHTILE;
4021
4022 25737 int32_t xoff = 0;
4023 25737 int32_t yoff = 0;
4024
1/2
✓ Branch 0 taken 25737 times.
✗ Branch 1 not taken.
25737 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
4025 {
4026 xoff += (hxsz/2)-8;
4027 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
4028 }
4029
1/2
✓ Branch 0 taken 25737 times.
✗ Branch 1 not taken.
25737 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
4030 {
4031 yoff += (hysz/2)-8;
4032 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
4033 }
4034
4035
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 24326 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25737 switch(dmisc1)
4036 {
4037 case e1t5SHOTS: //BS-Aquamentus
4038 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
4039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4040 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
4041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4042
4043 [[fallthrough]];
4044 case e1t3SHOTSFAST:
4045 case e1t3SHOTS: //Aquamentus
4046
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
4047 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4048
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
4049 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4050
4051 [[fallthrough]];
4052 default:
4053
11/20
✓ Branch 0 taken 24739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24739 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24739 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 24739 times.
✓ Branch 12 taken 24739 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10988 times.
✓ Branch 15 taken 13751 times.
✓ Branch 16 taken 24739 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 24739 times.
✗ Branch 19 not taken.
24739 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4054 24739 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4055 24739 sfx(wpnsfx(wpn),pan(int32_t(x)));
4056 24739 break;
4057
4058 case e1tSLANT:
4059 {
4060 409 int32_t slant = 0;
4061
4062
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
4063 236 slant = left;
4064
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
4065 112 slant = right;
4066
4067
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4068 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4069 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
4070 319 break;
4071 }
4072
4073 case e1t8SHOTS: //Fire Wizzrobe
4074 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
4075 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4076 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4077 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
4078 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4079 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4080 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
4081 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4082 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4083 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
4084 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4085 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4086
4087 [[fallthrough]];
4088 case e1t4SHOTS: //Stalfos 3
4089
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
4090 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4091 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4092
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
4093 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4094 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4095
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
4096 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4097 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4098
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
4099 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4100 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4101 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
4102 589 break;
4103
4104 case e1tSUMMON: // Bat Wizzrobe
4105 {
4106 //al_trace("Summon Bats\n");
4107 //zprint2("Summon Bats\n");
4108 if(dmisc4==0) break; // Summon 0
4109
4110 int32_t bc=0;
4111
4112 for(int32_t gc=0; gc<guys.Count(); gc++)
4113 {
4114 if((((enemy*)guys.spr(gc))->id) == dmisc3)
4115 {
4116 ++bc;
4117 }
4118 }
4119
4120 if(bc<=40) // Not too many enemies
4121 {
4122 int32_t kids = guys.Count();
4123 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
4124
4125 for(int32_t i=0; i<bats; i++)
4126 {
4127 //zprint2("summon\n");
4128 //al_trace("summon\n");
4129 if(addchild(x,y,dmisc3,-10, this->script_UID))
4130 {
4131 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4132 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4133 //zprint2("Summoner Script UID: %d\n",this->script_UID);
4134
4135 }
4136 }
4137
4138 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4139 }
4140
4141 break;
4142 }
4143
4144 case e1tSUMMONLAYER: // Summoner
4145 {
4146 if(count_layer_enemies()==0)
4147 {
4148 break;
4149 }
4150
4151 int32_t kids = guys.Count();
4152
4153 if(kids<40)
4154 {
4155 int32_t newguys=(zc_oldrand()%3)+1;
4156 bool summoned=false;
4157
4158 for(int32_t i=0; i<newguys; i++)
4159 {
4160 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
4161 int32_t x2=0;
4162 int32_t y2=0;
4163
4164 for(int32_t k=0; k<20; ++k)
4165 {
4166 x2=16*((zc_oldrand()%12)+2);
4167 y2=16*((zc_oldrand()%7)+2);
4168
4169 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
4170 {
4171 //zprint2("summon\n");
4172 //al_trace("summon\n");
4173 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
4174 {
4175 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4176 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4177 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
4178 {
4179 ((enemy*)guys.spr(kids+i))->fakez = 64;
4180 ((enemy*)guys.spr(kids+i))->z = 0;
4181 }
4182 }
4183
4184 summoned=true;
4185 break;
4186 }
4187 }
4188 }
4189
4190 if(summoned)
4191 {
4192 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4193 }
4194 }
4195
4196 break;
4197 }
4198 }
4199 25657 }
4200
4201
4202 // Hit the shield(s)?
4203 // Apparently, this function is only used for hookshots...
4204 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
4205 {
4206
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
4207 106 return false;
4208
4209 292 bool ret = false;
4210
4211 // TODO: There must be some bitwise operations that can simplify this...
4212
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
4213
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
4214
4215
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
4216
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
4217
4218 300 return ret;
4219 406 }
4220
4221
4222 //! Weapon Editor for 2.6
4223 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
4224
4225
4226 //converts a wqeapon ID to its defence index.
4227 67140 int32_t weaponToDefence(int32_t wid)
4228 {
4229
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 30640 times.
✓ Branch 3 taken 6751 times.
✓ Branch 4 taken 17048 times.
✓ Branch 5 taken 654 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1261 times.
✓ Branch 10 taken 5722 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 817 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 952 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
67140 switch(wid)
4230 {
4231 case wNone: return -1;
4232 30640 case wSword: return edefSWORD;
4233 6751 case wBeam: return edefBEAM;
4234 17048 case wBrang: return edefBRANG;
4235 654 case wBomb: return edefBOMB;
4236 27 case wSBomb: return edefSBOMB;
4237 48 case wLitBomb: return edefBOMB;
4238 case wLitSBomb: return edefSBOMB;
4239 1261 case wArrow: return edefARROW;
4240 5722 case wFire: return edefFIRE;
4241 case wWhistle:
4242 {
4243 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
4244 return edefWhistle;
4245 }
4246 case wBait: return edefBAIT;
4247 163 case wWand: return edefWAND;
4248 817 case wMagic: return edefMAGIC;
4249 case wCatching: return -1;
4250 case wWind: return edefWIND;
4251 322 case wRefMagic: return edefREFMAGIC;
4252 920 case wRefFireball: return edefREFBALL;
4253 case wRefRock: return edefREFROCK;
4254 866 case wHammer: return edefHAMMER;
4255 406 case wHookshot: return edefHOOKSHOT;
4256 118 case wHSHandle: return edefHOOKSHOT;
4257 case wHSChain: return edefHOOKSHOT;
4258 case wSSparkle: return edefSPARKLE;
4259 325 case wFSparkle: return edefSPARKLE;
4260 case wSmack: return -1; // is this the candle object?
4261 case wPhantom: return -1; //engine created visual effects.
4262 case wCByrna: return edefBYRNA;
4263 11 case wRefBeam: return edefREFBEAM;
4264 case wStomp: return edefSTOMP;
4265 case wScript1: return edefSCRIPT01;
4266 case wScript2: return edefSCRIPT02;
4267 12 case wScript3: return edefSCRIPT03;
4268 77 case wScript4: return edefSCRIPT04;
4269 case wScript5: return edefSCRIPT05;
4270 case wScript6: return edefSCRIPT06;
4271 case wScript7: return edefSCRIPT07;
4272 case wScript8: return edefSCRIPT08;
4273 case wScript9: return edefSCRIPT09;
4274 952 case wScript10: return edefSCRIPT10;
4275 case wIce: return edefICE;
4276 case wSound: return edefSONIC;
4277 case wThrown: return edefTHROWN;
4278 //case wPot: return edefPOT;
4279 // case wLitZap: return edefELECTRIC;
4280 // case wZ3Sword: return edefZ3SWORD;
4281 // case wLASWord: return edefLASWORD;
4282 // case wSpinAttk: return edefSPINATTK;
4283 // case wShield: return edefSHIELD;
4284 // case wTrowel: return edefTROWEL;
4285
4286 default: return -1;
4287 }
4288 67140 }
4289
4290 67140 int32_t getDefType(weapon *w)
4291 {
4292 67140 int32_t id = getWeaponID(w);
4293 67140 int32_t edef = weaponToDefence(id);
4294
2/2
✓ Branch 0 taken 66616 times.
✓ Branch 1 taken 524 times.
67140 if(edef == edefHOOKSHOT)
4295 {
4296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
4297 return edefSwitchHook;
4298 524 }
4299 67140 return edef;
4300 67140 }
4301
4302 116826 int32_t getWeaponID(weapon *w)
4303 {
4304 116826 int32_t usewpn = w->useweapon;
4305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116826 times.
116826 return (usewpn > 0) ? usewpn : w->id;
4306 }
4307
4308 67140 int32_t enemy::resolveEnemyDefence(weapon *w)
4309 {
4310 //sword edef is 9, but we're reading it at 0
4311 //,
4312 67140 int32_t weapondef = 0;
4313 67140 int32_t wdeftype = getDefType(w);
4314 67140 int32_t usedef = w->usedefence;
4315
4316
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
67140 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
4317 {
4318 weapondef = usedef*-1;
4319 }
4320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67140 times.
67140 else if(unsigned(wdeftype) < edefLAST255)
4321 {
4322 67140 weapondef = wdeftype;
4323 67140 }
4324 67140 return weapondef;
4325 }
4326
4327 72791 byte get_def_ignrflag(int32_t edef)
4328 {
4329
3/3
✓ Branch 0 taken 61305 times.
✓ Branch 1 taken 2312 times.
✓ Branch 2 taken 9174 times.
72791 switch(edef)
4330 {
4331 case edIGNORE:
4332 case edIGNOREL1:
4333 case edSTUNORIGNORE:
4334 9174 return WPNUNB_IGNR;
4335 case edSTUNORCHINK:
4336 case edCHINK:
4337 case edCHINKL1:
4338 case edCHINKL2:
4339 case edCHINKL4:
4340 case edCHINKL6:
4341 case edCHINKL8:
4342 case edCHINKL10:
4343 case edLEVELCHINK2:
4344 case edLEVELCHINK3:
4345 case edLEVELCHINK4:
4346 case edLEVELCHINK5:
4347 2312 return WPNUNB_BLOCK;
4348 }
4349 61305 return 0;
4350 72791 }
4351
4352 72791 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
4353 {
4354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72791 times.
72791 if(!(unblockable&get_def_ignrflag(edef))) return edef;
4355 switch(edef)
4356 {
4357 case edIGNORE:
4358 case edIGNOREL1:
4359 case edCHINK:
4360 case edCHINKL1:
4361 case edCHINKL2:
4362 case edCHINKL4:
4363 case edCHINKL6:
4364 case edCHINKL8:
4365 case edCHINKL10:
4366 case edLEVELCHINK2:
4367 case edLEVELCHINK3:
4368 case edLEVELCHINK4:
4369 case edLEVELCHINK5:
4370 return edNORMAL;
4371 case edSTUNORIGNORE:
4372 case edSTUNORCHINK:
4373 return edSTUNONLY;
4374 }
4375 return edef;
4376 72791 }
4377
4378 // Do we do damage?
4379 // 0: takehit returns 0
4380 // 1: takehit returns 1
4381 // -1: do damage
4382 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
4383 66188 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
4384 {
4385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66188 times.
66188 if(switch_hooked) return 0;
4386 66188 int32_t tempx = x;
4387 66188 int32_t tempy = y;
4388 66188 int32_t the_defence = 0;
4389
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 if ( edef < 0 ) //we are using a specific base default defence for a weapon
4390 {
4391 the_defence = edef*-1; //A specific defence type.
4392 }
4393 66188 else the_defence = defense[edef];
4394
4395 66188 the_defence = conv_edef_unblockable(the_defence, unblockable);
4396
4397
3/4
✓ Branch 0 taken 4257 times.
✓ Branch 1 taken 61931 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4257 times.
66188 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
4398 {
4399
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4256 times.
✓ Branch 2 taken 1 times.
4257 switch(the_defence)
4400 {
4401 case edIGNORE:
4402 1 return 0;
4403 case edIGNOREL1:
4404 case edSTUNORIGNORE:
4405 if(*power <= 0)
4406 return 0;
4407 }
4408 4256 sfx(WAV_CHINK,pan(int32_t(x)));
4409 4256 return 1;
4410 }
4411
4412 61931 int32_t new_id = id;
4413 61931 int32_t effect_type = dmisc15;
4414 61931 int32_t delay_timer = 90;
4415 61931 enemy *gleeok = NULL;
4416 61931 enemy *ptra = NULL;
4417 61931 int32_t c = 0;
4418
4419
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1328 times.
✓ Branch 6 taken 767 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 182 times.
✓ Branch 13 taken 7845 times.
✓ Branch 14 taken 137 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 49243 times.
61931 switch(the_defence)
4420 {
4421 case edREPLACE:
4422 {
4423 sclk = 0;
4424 if ( dmisc16 > 0 ) new_id = dmisc16;
4425 else new_id = id+1;
4426 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
4427 if ( dmisc17 > 0 ) delay_timer = dmisc17;
4428 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
4429
4430 //Z_scripterrlog("new id is %d\n", new_id);
4431 switch(guysbuf[new_id&0xFFF].family)
4432 {
4433 //Fixme: possible enemy memory leak. (minor)
4434 case eeWALK:
4435 {
4436 enemy *e = new eStalfos(x,y,new_id,clk);
4437 guys.add(e);
4438 }
4439 break;
4440
4441 case eeLEV:
4442 {
4443 enemy *e = new eLeever(x,y,new_id,clk);
4444 guys.add(e);
4445 }
4446 break;
4447
4448 case eeTEK:
4449 {
4450 enemy *e = new eTektite(x,y,new_id,clk);
4451 guys.add(e);
4452 }
4453 break;
4454
4455 case eePEAHAT:
4456 {
4457 enemy *e = new ePeahat(x,y,new_id,clk);
4458 guys.add(e);
4459 }
4460 break;
4461
4462 case eeZORA:
4463 {
4464 enemy *e = new eZora(x,y,new_id,clk);
4465 guys.add(e);
4466 }
4467 break;
4468
4469 case eeGHINI:
4470 {
4471 enemy *e = new eGhini(x,y,new_id,clk);
4472 guys.add(e);
4473 }
4474 break;
4475
4476 case eeKEESE:
4477 {
4478 enemy *e = new eKeese(x,y,new_id,clk);
4479 guys.add(e);
4480 }
4481 break;
4482
4483 case eeWIZZ:
4484 {
4485 enemy *e = new eWizzrobe(x,y,new_id,clk);
4486 guys.add(e);
4487 }
4488 break;
4489
4490 case eePROJECTILE:
4491 {
4492 enemy *e = new eProjectile(x,y,new_id,clk);
4493 guys.add(e);
4494 }
4495 break;
4496
4497 case eeWALLM:
4498 {
4499 enemy *e = new eWallM(x,y,new_id,clk);
4500 guys.add(e);
4501 }
4502 break;
4503
4504 case eeAQUA:
4505 {
4506 enemy *e = new eAquamentus(x,y,new_id,clk);
4507 guys.add(e);
4508 e->x = x;
4509 e->y = y;
4510 }
4511 break;
4512
4513 case eeMOLD:
4514 {
4515 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
4516 guys.add(e);
4517 e->x = x;
4518 e->y = y;
4519 }
4520 break;
4521
4522 case eeMANHAN:
4523 {
4524 enemy *e = new eManhandla(x,y,new_id,clk);
4525 guys.add(e);
4526 e->x = x;
4527 e->y = y;
4528 }
4529 break;
4530
4531 case eeGLEEOK:
4532 {
4533 *power = 0;
4534 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
4535 guys.add(gleeok);
4536 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4537 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4538 new_id &= 0xFFF;
4539 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4540 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4541 for(int32_t i=0; i<head_cnt; i++)
4542 {
4543 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4544 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4545 {
4546 al_trace("Gleeok head %d could not be created!\n",i+1);
4547
4548 for(int32_t j=0; j<i+1; j++)
4549 {
4550 guys.del(guys.Count()-1);
4551 }
4552
4553 break;
4554 }
4555 else
4556 {
4557 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4558 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4559 }
4560
4561 c-=guysbuf[new_id].misc4;
4562 //gleeok->x = x;
4563 //gleeok->y = y;
4564 //gleeok = e;
4565 }
4566 return 1;
4567 }
4568
4569 case eeGHOMA:
4570 {
4571 enemy *e = new eGohma(x,y,new_id,clk);
4572 guys.add(e);
4573 e->x = x;
4574 e->y = y;
4575 }
4576 break;
4577
4578 case eeLANM:
4579 {
4580 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
4581 guys.add(e);
4582 e->x = x;
4583 e->y = y;
4584 }
4585 break;
4586
4587 case eeGANON:
4588 {
4589 enemy *e = new eGanon(x,y,new_id,clk);
4590 guys.add(e);
4591 e->x = x;
4592 e->y = y;
4593 }
4594 break;
4595
4596 case eeFAIRY:
4597 {
4598 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
4599 guys.add(e);
4600 e->x = x;
4601 e->y = y;
4602 }
4603 break;
4604
4605 case eeFIRE:
4606 {
4607 enemy *e = new eFire(x,y,new_id,clk);
4608 guys.add(e);
4609 e->x = x;
4610 e->y = y;
4611 }
4612 break;
4613
4614 case eeOTHER:
4615 {
4616 enemy *e = new eOther(x,y,new_id,clk);
4617 guys.add(e);
4618 e->x = x;
4619 e->y = y;
4620 }
4621 break;
4622
4623 case eeSPINTILE:
4624 {
4625 enemy *e = new eSpinTile(x,y,new_id,clk);
4626 guys.add(e);
4627 e->x = x;
4628 e->y = y;
4629 }
4630 break;
4631
4632 // and these enemies use the misc10/misc2 value
4633 case eeROCK:
4634 {
4635 switch(guysbuf[new_id&0xFFF].misc10)
4636 {
4637 case 1:
4638 {
4639 enemy *e = new eBoulder(x,y,new_id,clk);
4640 guys.add(e);
4641 e->x = x;
4642 e->y = y;
4643 }
4644 break;
4645
4646 case 0:
4647 default:
4648 {
4649 enemy *e = new eRock(x,y,new_id,clk);
4650 guys.add(e);
4651 e->x = x;
4652 e->y = y;
4653 }
4654 break;
4655 }
4656
4657 break;
4658 }
4659
4660 case eeTRAP:
4661 {
4662 switch(guysbuf[new_id&0xFFF].misc2)
4663 {
4664 case 1:
4665 {
4666 enemy *e = new eTrap2(x,y,new_id,clk);
4667 guys.add(e);
4668 e->x = x;
4669 e->y = y;
4670 }
4671 break;
4672
4673 case 0:
4674 default:
4675 {
4676 enemy *e = new eTrap(x,y,new_id,clk);
4677 guys.add(e);
4678 e->x = x;
4679 e->y = y;
4680 }
4681 break;
4682 }
4683
4684 break;
4685 }
4686
4687 case eeDONGO:
4688 {
4689 switch(guysbuf[new_id&0xFFF].misc10)
4690 {
4691 case 1:
4692 {
4693 enemy *e = new eDodongo2(x,y,new_id,clk);
4694 guys.add(e);
4695 e->x = x;
4696 e->y = y;
4697 }
4698 break;
4699
4700 case 0:
4701 default:
4702 {
4703 enemy *e = new eDodongo(x,y,new_id,clk);
4704 guys.add(e);
4705 e->x = x;
4706 e->y = y;
4707 }
4708 break;
4709 }
4710
4711 break;
4712 }
4713
4714 case eeDIG:
4715 {
4716 switch(guysbuf[new_id&0xFFF].misc10)
4717 {
4718 case 1:
4719 {
4720 enemy *e = new eLilDig(x,y,new_id,clk);
4721 guys.add(e);
4722 e->x = x;
4723 e->y = y;
4724 }
4725 break;
4726
4727 case 0:
4728 default:
4729 {
4730 enemy *e = new eBigDig(x,y,new_id,clk);
4731 guys.add(e);
4732 e->x = x;
4733 e->y = y;
4734 }
4735 break;
4736 }
4737
4738 break;
4739 }
4740
4741 case eePATRA:
4742 {
4743 switch(guysbuf[new_id&0xFFF].misc10)
4744 {
4745 case 1:
4746 {
4747 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
4748 {
4749 enemy *e = new ePatraBS(x,y,new_id,clk);
4750 guys.add(e);
4751 e->x = x;
4752 e->y = y;
4753 break;
4754 }
4755 }
4756 [[fallthrough]];
4757 case 0:
4758 default:
4759 {
4760 enemy *e = new ePatra(x,y,new_id,clk);
4761 guys.add(e);
4762 e->x = x;
4763 e->y = y;
4764 }
4765 break;
4766 }
4767
4768 break;
4769 }
4770
4771 case eeGUY:
4772 {
4773 switch(guysbuf[new_id&0xFFF].misc10)
4774 {
4775 case 1:
4776 {
4777 enemy *e = new eTrigger(x,y,new_id,clk);
4778 guys.add(e);
4779 }
4780 break;
4781
4782 case 0:
4783 default:
4784 {
4785 enemy *e = new eNPC(x,y,new_id,clk);
4786 guys.add(e);
4787 }
4788 break;
4789 }
4790
4791 break;
4792 }
4793
4794 case eeSCRIPT01:
4795 case eeSCRIPT02:
4796 case eeSCRIPT03:
4797 case eeSCRIPT04:
4798 case eeSCRIPT05:
4799 case eeSCRIPT06:
4800 case eeSCRIPT07:
4801 case eeSCRIPT08:
4802 case eeSCRIPT09:
4803 case eeSCRIPT10:
4804 case eeSCRIPT11:
4805 case eeSCRIPT12:
4806 case eeSCRIPT13:
4807 case eeSCRIPT14:
4808 case eeSCRIPT15:
4809 case eeSCRIPT16:
4810 case eeSCRIPT17:
4811 case eeSCRIPT18:
4812 case eeSCRIPT19:
4813 case eeSCRIPT20:
4814 {
4815 enemy *e = new eScript(x,y,new_id,clk);
4816 guys.add(e);
4817 e->x = x;
4818 e->y = y;
4819 break;
4820 }
4821
4822
4823 case eeFFRIENDLY01:
4824 case eeFFRIENDLY02:
4825 case eeFFRIENDLY03:
4826 case eeFFRIENDLY04:
4827 case eeFFRIENDLY05:
4828 case eeFFRIENDLY06:
4829 case eeFFRIENDLY07:
4830 case eeFFRIENDLY08:
4831 case eeFFRIENDLY09:
4832 case eeFFRIENDLY10:
4833 {
4834 enemy *e = new eFriendly(x,y,new_id,clk);
4835 guys.add(e);
4836 e->x = x;
4837 e->y = y;
4838 break;
4839 }
4840
4841
4842 default: break;
4843 }
4844
4845 // add segments of segmented enemies
4846 int32_t c=0;
4847
4848 switch(guysbuf[new_id&0xFFF].family)
4849 {
4850 case eeMOLD:
4851 {
4852 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4853 new_id &= 0xFFF;
4854
4855 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
4856 {
4857 //christ this is messy -DD
4858 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
4859
4860 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
4861 {
4862 al_trace("Moldorm segment %d could not be created!\n",i+1);
4863
4864 for(int32_t j=0; j<i+1; j++)
4865 guys.del(guys.Count()-1);
4866
4867 return 0;
4868 }
4869
4870 if(i>0)
4871 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4872
4873
4874 }
4875
4876 break;
4877 }
4878
4879 case eeLANM:
4880 {
4881 new_id &= 0xFFF;
4882 int32_t shft = guysbuf[new_id].misc2;
4883 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4884 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
4885
4886 if(!guys.add(e))
4887 {
4888 al_trace("Lanmola segment 1 could not be created!\n");
4889 guys.del(guys.Count()-1);
4890 return 0;
4891 }
4892 e->x = x;
4893 e->y = y;
4894
4895
4896
4897 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
4898 {
4899 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
4900 if(!guys.add(e2))
4901 {
4902 al_trace("Lanmola segment %d could not be created!\n",i+1);
4903
4904 for(int32_t j=0; j<i+1; j++)
4905 guys.del(guys.Count()-1);
4906
4907 return 0;
4908 }
4909 e2->x = x;
4910 e2->y = y;
4911
4912 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4913
4914 }
4915 }
4916 break;
4917
4918 case eeMANHAN:
4919 new_id &= 0xFFF;
4920
4921 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
4922 {
4923 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
4924 {
4925 al_trace("Manhandla head %d could not be created!\n",i+1);
4926
4927 for(int32_t j=0; j<i+1; j++)
4928 {
4929 guys.del(guys.Count()-1);
4930 }
4931
4932 return 0;
4933 }
4934
4935
4936 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
4937 }
4938
4939 break;
4940
4941 case eeGLEEOK:
4942 {
4943 /*
4944 new_id &= 0xFFF;
4945 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4946 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4947 for(int32_t i=0; i<head_cnt; i++)
4948 {
4949 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4950 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4951 {
4952 al_trace("Gleeok head %d could not be created!\n",i+1);
4953
4954 for(int32_t j=0; j<i+1; j++)
4955 {
4956 guys.del(guys.Count()-1);
4957 }
4958
4959 break;
4960 }
4961
4962 c-=guysbuf[new_id].misc4;
4963 */
4964
4965 // }
4966 }
4967 break;
4968
4969
4970 case eePATRA:
4971 {
4972 new_id &= 0xFFF;
4973 int32_t outeyes = 0;
4974 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
4975
4976 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
4977 {
4978 if(!((guysbuf[new_id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
4979 {
4980 al_trace("Patra outer eye %d could not be created!\n",i+1);
4981
4982 for(int32_t j=0; j<i+1; j++)
4983 guys.del(guys.Count()-1);
4984
4985 return 0;
4986 }
4987 else
4988 outeyes++;
4989
4990
4991 }
4992
4993 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
4994 {
4995 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
4996 {
4997 al_trace("Patra inner eye %d could not be created!\n",i+1);
4998
4999 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
5000 guys.del(guys.Count()-1);
5001
5002 return 0;
5003 }
5004
5005
5006 }
5007 delete ptra;
5008 break;
5009 }
5010 }
5011
5012
5013
5014 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
5015 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
5016 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
5017 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
5018 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
5019 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
5020 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
5021 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
5022 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
5023 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
5024 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
5025 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
5026 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
5027 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
5028
5029
5030 item_set = 0; //Do not make a drop.
5031
5032 switch(effect_type)
5033 {
5034 case -7:
5035 {
5036 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
5037 Lwpns.add(w);
5038 break;
5039 }
5040 case -6:
5041 {
5042 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
5043 Lwpns.add(w);
5044 break;
5045 }
5046 case -5:
5047 {
5048 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5049 Lwpns.add(w);
5050 break;
5051 }
5052 case -4:
5053 {
5054 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5055 Lwpns.add(w);
5056 break;
5057 }
5058 case -3: explode(1); break;
5059 case -2: explode(2); break;
5060 case -1: explode(0); break;
5061 case 0: break;
5062
5063 default:
5064 {
5065 //Dummy weapon function
5066 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
5067 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
5068 Lwpns.add(w);
5069 break;
5070 }
5071 }
5072
5073
5074 yofs = -32768;
5075 switch(guysbuf[new_id&0xFFF].family)
5076 {
5077 case eeGLEEOK:
5078 {
5079 Z_scripterrlog("Replacing a gleeok.\n");
5080 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
5081 hp = -999;
5082 tempenemy->hp = -999;
5083 break;
5084
5085 }
5086 default:
5087 hp = -1000; break;
5088 }
5089 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
5090 return 1;
5091
5092 }
5093 case edSPLIT:
5094 {
5095 //int32_t ex = x; int32_t ey = y;
5096 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5097 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5098 /*
5099 if ( txsx > 1 )
5100 {
5101 ex += ( txsz-1 ) * 8; //from its middle
5102 }
5103 if ( tysx > 1 )
5104 {
5105 ey += ( tysz-1 ) * 8; //from its middle
5106 }
5107 */
5108 for ( int32_t q = 0; q < dmisc4; q++ )
5109 {
5110
5111 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
5112 addenemy(
5113 //ex,ey,
5114 x,y,
5115 dmisc3+0x1000,-15);
5116 //addenemy(ex,ey,dmisc3,0);
5117
5118 }
5119 item_set = 0; //Do not make a drop.
5120 hp = -1000;
5121 return -1;
5122
5123 }
5124 case edSUMMON:
5125 {
5126
5127
5128 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5129 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5130 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
5131 for ( int32_t q = 0; q < summon_count; q++ )
5132 {
5133 int32_t x2=16*((zc_oldrand()%12)+2);
5134 int32_t y2=16*((zc_oldrand()%7)+2);
5135 addenemy(
5136 //(x+(txsz*16)/2),(y+(tysz*16)/2)
5137 x2,y2,
5138 dmisc3+0x1000,-15);
5139 //addenemy(ex,ey,dmisc3,0);
5140
5141 }
5142 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
5143 return -1;
5144
5145 }
5146
5147 case edEXPLODESMALL:
5148 {
5149 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
5150 Ewpns.add(ew);
5151 item_set = 0; //Should we make a drop?
5152 hp = -1000;
5153 return -1;
5154 }
5155
5156
5157 case edEXPLODEHARMLESS:
5158 {
5159 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5160 Ewpns.add(ew);
5161 ew->hyofs = -32768;
5162 item_set = 0; //Should we make a drop?
5163 hp = -1000;
5164 return -1;
5165 }
5166
5167
5168 case edEXPLODELARGE:
5169 {
5170 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5171 Ewpns.add(ew);
5172
5173 hp = -1000;
5174 return -1;
5175 }
5176
5177
5178 case edTRIGGERSECRETS:
5179 {
5180 hidden_entrance(0, true, false, -4);
5181 return -1;
5182 }
5183
5184 case edSTUNORCHINK:
5185
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5186 {
5187 sfx(WAV_CHINK,pan(int32_t(x)));
5188 return 1;
5189 }
5190
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
5191 {
5192 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
5193 511 sfx(WAV_CHINK,pan(int32_t(x)));
5194 511 return 1;
5195 }
5196 [[fallthrough]];
5197
5198 case edSTUNORIGNORE:
5199
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1168 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4493 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5200 {
5201 sfx(WAV_CHINK,pan(int32_t(x)));
5202 return 1;
5203 }
5204
2/2
✓ Branch 0 taken 719 times.
✓ Branch 1 taken 1887 times.
2606 else if(*power <= 0)
5205 719 return 0;
5206 [[fallthrough]];
5207
5208 case edSTUNONLY:
5209
7/10
✓ Branch 0 taken 2654 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2654 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2654 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2598 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2625 times.
✓ Branch 9 taken 29 times.
2654 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5210 {
5211 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5212 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5213 29 return 1;
5214 }
5215
3/4
✓ Branch 0 taken 2006 times.
✓ Branch 1 taken 619 times.
✓ Branch 2 taken 2006 times.
✗ Branch 3 not taken.
2625 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5216 {
5217 sfx(WAV_CHINK,pan(int32_t(x)));
5218 return 1;
5219 }
5220 else
5221 {
5222 2625 stunclk=160;
5223 2625 sfx(WAV_EHIT,pan(int32_t(x)));
5224
5225 2625 return 1;
5226 }
5227
5228 case edCHINKL1:
5229 if(*power >= 1*game->get_hero_dmgmult()) break;
5230 [[fallthrough]];
5231 case edCHINKL2:
5232
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
5233 [[fallthrough]];
5234 case edCHINKL4:
5235
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
5236 [[fallthrough]];
5237 case edCHINKL6:
5238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
5239 [[fallthrough]];
5240 case edCHINKL8:
5241
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
5242 [[fallthrough]];
5243 case edCHINKL10:
5244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
5245 [[fallthrough]];
5246 case edCHINK:
5247 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
5248 202 sfx(WAV_CHINK,pan(int32_t(x)));
5249 202 return 1;
5250
5251 case edIGNOREL1:
5252 if(*power > 0) break;
5253 [[fallthrough]];
5254
5255 case edIGNORE:
5256 7845 return 0;
5257
5258 case ed1HKO:
5259 315 *power = hp;
5260 315 return -2;
5261
5262 case ed2x:
5263 {
5264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
5265 //int32_t pow = *power;
5266 //*power = vbound((pow*2),0,214747);
5267 71 return -1;
5268 }
5269 case ed3x:
5270 {
5271 *power = zc_max(1,*power*3);
5272 //int32_t pow = *power;
5273 //*power = vbound((pow*3),0,214747);
5274 return -1;
5275 }
5276
5277 case ed4x:
5278 {
5279 *power = zc_max(1,*power*4);
5280 //int32_t pow = *power;
5281 //*power = vbound((pow*4),0,214747);
5282 return -1;
5283 }
5284
5285
5286 case edHEAL:
5287 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5288 //int32_t pow = *power;
5289 //*power = vbound((pow*-1),0,214747);
5290 //break;
5291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
5292 79 return -1;
5293 }
5294 /*
5295 case edLEVELDAMAGE:
5296 {
5297 int32_t pow = *power;
5298 int32_t lvl = *level;
5299 *power = vbound((pow*lvl),0,214747);
5300 break;
5301 }
5302 case edLEVELREDUCTION:
5303 {
5304 int32_t pow = *power;
5305 int32_t lvl = *level;
5306 *power = vbound((pow/lvl),0,214747);
5307 break;
5308 }
5309 */
5310
5311 case edQUARTDAMAGE:
5312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 *power = zc_max(1,*power/2);
5313
5314 [[fallthrough]];
5315 case edHALFDAMAGE:
5316
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 194 times.
195 *power = zc_max(1,*power/2);
5317 195 break;
5318
5319 case edSWITCH:
5320 {
5321 if(Hero.switchhookclk) return 0; //Already switching!
5322 switch(family)
5323 {
5324 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
5325 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
5326 return 0;
5327 }
5328 hooked_combopos = -1;
5329 hooked_layerbits = 0;
5330 switching_object = this;
5331 switch_hooked = true;
5332 Hero.doSwitchHook(game->get_switchhookstyle());
5333 if(QMisc.miscsfx[sfxSWITCHED])
5334 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
5335 return 1;
5336 }
5337
5338 case 0:
5339 {
5340
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49243 times.
49243 if(edef == edefSwitchHook)
5341 return -1;
5342
6/6
✓ Branch 0 taken 12302 times.
✓ Branch 1 taken 36941 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 12273 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
49243 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK) && *power == 0)
5343 {
5344 13 sfx(WAV_CHINK,pan(int32_t(x)));
5345 13 return 1;
5346 }
5347
5348 }
5349 49230 }
5350
5351 49522 return -1;
5352 66188 }
5353
5354 66188 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
5355 {
5356
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 int wuid = w?w->getUID():0;
5357
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 bool fakeweap = (w && !Lwpns.getByUID(wuid));
5358
5359
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 if(fakeweap)
5360 Lwpns.add(w);
5361 66188 std::vector<int32_t> &ev = FFCore.eventData;
5362 66188 ev.clear();
5363 66188 ev.push_back(*power*10000);
5364 66188 ev.push_back(edef*10000);
5365 66188 ev.push_back(unblockable*10000);
5366 66188 ev.push_back(wpnId*10000);
5367 66188 ev.push_back(0);
5368 66188 ev.push_back(getUID());
5369 66188 ev.push_back(wuid);
5370
5371 66188 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
5372 66188 *power = ev[0]/10000;
5373 66188 edef = ev[1]/10000;
5374 66188 unblockable = byte(ev[2]/10000);
5375 66188 wpnId = ev[3] / 10000;
5376 66188 bool nullify = ev[4]!=0;
5377 66188 ev.clear();
5378 66188 int ret = 0;
5379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66188 times.
66188 if(!nullify)
5380 {
5381 66188 ret = defendNew(wpnId, power, edef, unblockable);
5382
2/2
✓ Branch 0 taken 17195 times.
✓ Branch 1 taken 48993 times.
66188 if(ret == -1)
5383 {
5384 48993 ev.push_back(*power*10000);
5385 48993 ev.push_back(edef*10000);
5386 48993 ev.push_back(unblockable*10000);
5387 48993 ev.push_back(wpnId*10000);
5388 48993 ev.push_back(0);
5389 48993 ev.push_back(getUID());
5390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48993 times.
48993 ev.push_back(w?w->getUID():0);
5391
5392 48993 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
5393 48993 *power = ev[0]/10000;
5394 48993 nullify = ev[4]!=0;
5395 48993 ev.clear();
5396 48993 }
5397 66188 }
5398
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 if(fakeweap)
5399 Lwpns.remove(w);
5400
5401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66188 times.
66188 return nullify ? 0 : ret;
5402 }
5403
5404 49686 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
5405 {
5406
2/2
✓ Branch 0 taken 49457 times.
✓ Branch 1 taken 229 times.
49686 if(!realweap) realweap = w;
5407 49686 int32_t wid = getWeaponID(w);
5408
5409 49686 int32_t edef = resolveEnemyDefence(w);
5410
2/2
✓ Branch 0 taken 1255 times.
✓ Branch 1 taken 48431 times.
49686 if(QHeader.zelda_version > 0x250)
5411 1255 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5412
2/3
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 47479 times.
✗ Branch 2 not taken.
48431 switch(wid)
5413 {
5414 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
5415 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
5416 952 return defend(wpnId, power, edefSCRIPT);
5417
5418 case wWhistle:
5419 return -1;
5420
5421 default:
5422 47479 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5423 }
5424 49686 }
5425
5426
5427 // Check defenses without actually acting on them.
5428 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
5429 {
5430
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
5431 {
5432 case edSTUNONLY:
5433 8 return false;
5434 case edSTUNORCHINK:
5435 case edCHINK:
5436 9574 return unblockable&WPNUNB_BLOCK;
5437 case edSTUNORIGNORE:
5438 case edIGNORE:
5439 2059 return unblockable&WPNUNB_IGNR;
5440
5441 case edIGNOREL1:
5442 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
5443 case edCHINKL1:
5444 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
5445
5446 case edCHINKL2:
5447 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
5448
5449 case edCHINKL4:
5450 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
5451
5452 case edCHINKL6:
5453 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
5454
5455 case edCHINKL8:
5456 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
5457 }
5458
5459 325 return true;
5460 11966 }
5461
5462 // Do we do damage?
5463 // 0: takehit returns 0
5464 // 1: takehit returns 1
5465 // -1: do damage
5466 952 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
5467 {
5468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 if(shieldCanBlock)
5469 {
5470 switch(defense[edef])
5471 {
5472 case edIGNORE:
5473 return 0;
5474 case edIGNOREL1:
5475 case edSTUNORIGNORE:
5476 if(*power <= 0)
5477 return 0;
5478 }
5479
5480 sfx(WAV_CHINK,pan(int32_t(x)));
5481 return 1;
5482 }
5483
5484
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 759 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
952 switch(defense[edef])
5485 {
5486 case edSTUNORCHINK:
5487 if(*power <= 0)
5488 {
5489 sfx(WAV_CHINK,pan(int32_t(x)));
5490 return 1;
5491 }
5492
5493 [[fallthrough]];
5494 case edSTUNORIGNORE:
5495 if(*power <= 0)
5496 return 0;
5497
5498 [[fallthrough]];
5499 case edSTUNONLY:
5500 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5501 return 1;
5502
5503 stunclk=160;
5504 sfx(WAV_EHIT,pan(int32_t(x)));
5505 return 1;
5506
5507 case edFREEZE:
5508 frozenclock=-1;
5509 //sfx(WAV_FREEZE,pan(int32_t(x)));
5510 return 1;
5511
5512 case edCHINKL1:
5513 if(*power >= 1*game->get_hero_dmgmult()) break;
5514 [[fallthrough]];
5515 case edCHINKL2:
5516 if(*power >= 2*game->get_hero_dmgmult()) break;
5517 [[fallthrough]];
5518 case edCHINKL4:
5519 if(*power >= 4*game->get_hero_dmgmult()) break;
5520 [[fallthrough]];
5521 case edCHINKL6:
5522 if(*power >= 6*game->get_hero_dmgmult()) break;
5523 [[fallthrough]];
5524 case edCHINKL8:
5525 if(*power >= 8*game->get_hero_dmgmult()) break;
5526 [[fallthrough]];
5527 case edCHINKL10:
5528 if(*power >= 10*game->get_hero_dmgmult()) break;
5529 [[fallthrough]];
5530 case edCHINK:
5531 sfx(WAV_CHINK,pan(int32_t(x)));
5532 return 1;
5533 case edTRIGGERSECRETS:
5534 hidden_entrance(0, true, false, -4);
5535 break;
5536
5537 case edIGNOREL1:
5538 if(*power > 0) break;
5539 [[fallthrough]];
5540 case edIGNORE:
5541 759 return 0;
5542
5543 case ed1HKO:
5544 *power = hp;
5545 return -2;
5546
5547 case ed2x:
5548 {
5549 *power = zc_max(1,*power*2);
5550 //int32_t pow = *power;
5551 //*power = vbound((pow*2),0,214747);
5552 return -1;
5553 }
5554 case ed3x:
5555 {
5556 *power = zc_max(1,*power*3);
5557 //int32_t pow = *power;
5558 //*power = vbound((pow*3),0,214747);
5559 return -1;
5560 }
5561
5562 case ed4x:
5563 {
5564 *power = zc_max(1,*power*4);
5565 //int32_t pow = *power;
5566 //*power = vbound((pow*4),0,214747);
5567 return -1;
5568 }
5569
5570
5571 case edHEAL:
5572 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5573 //int32_t pow = *power;
5574 //*power = vbound((pow*-1),0,214747);
5575 //break;
5576 *power = zc_min(0,*power*-1);
5577 return -1;
5578 }
5579 /*
5580 case edLEVELDAMAGE:
5581 {
5582 int32_t pow = *power;
5583 int32_t lvl = *level;
5584 *power = vbound((pow*lvl),0,214747);
5585 break;
5586 }
5587 case edLEVELREDUCTION:
5588 {
5589 int32_t pow = *power;
5590 int32_t lvl = *level;
5591 *power = vbound((pow/lvl),0,214747);
5592 break;
5593 }
5594 */
5595
5596
5597 case edQUARTDAMAGE:
5598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
5599
5600 [[fallthrough]];
5601 case edHALFDAMAGE:
5602
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 *power = zc_max(1,*power/2);
5603 7 break;
5604 }
5605
5606 193 return -1;
5607 952 }
5608
5609 // Defend against a particular item class.
5610 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
5611 {
5612 int32_t def=-1;
5613
5614 switch(wpnId)
5615 {
5616 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
5617 case wBrang:
5618 def = defend(wpnId, power, edefBRANG);
5619 break;
5620
5621 case wHookshot:
5622 def = defend(wpnId, power, edefHOOKSHOT);
5623 break;
5624
5625 // Anyway...
5626 case wBomb:
5627 def = defend(wpnId, power, edefBOMB);
5628 break;
5629
5630 case wSBomb:
5631 def = defend(wpnId, power, edefSBOMB);
5632 break;
5633
5634 case wArrow:
5635 def = defend(wpnId, power, edefARROW);
5636 break;
5637
5638 case wFire:
5639 def = defend(wpnId, power, edefFIRE);
5640 break;
5641
5642 case wWand:
5643 def = defend(wpnId, power, edefWAND);
5644 break;
5645
5646 case wMagic:
5647 def = defend(wpnId, power, edefMAGIC);
5648 break;
5649
5650 case wHammer:
5651 def = defend(wpnId, power, edefHAMMER);
5652 break;
5653
5654 case wSword:
5655 def = defend(wpnId, power, edefSWORD);
5656 break;
5657
5658 case wBeam:
5659 def = defend(wpnId, power, edefBEAM);
5660 break;
5661
5662 case wRefBeam:
5663 def = defend(wpnId, power, edefREFBEAM);
5664 break;
5665
5666 case wRefMagic:
5667 def = defend(wpnId, power, edefREFMAGIC);
5668 break;
5669
5670 case wRefFireball:
5671 def = defend(wpnId, power, edefREFBALL);
5672 break;
5673
5674 case wRefRock:
5675 def = defend(wpnId, power, edefREFROCK);
5676 break;
5677
5678 case wStomp:
5679 def = defend(wpnId, power, edefSTOMP);
5680 break;
5681
5682 case wCByrna:
5683 def = defend(wpnId, power, edefBYRNA);
5684 break;
5685
5686 case wScript1:
5687 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
5688 else def = defend(wpnId, power, edefSCRIPT);
5689 break;
5690
5691 case wScript2:
5692 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
5693 else def = defend(wpnId, power, edefSCRIPT);
5694 break;
5695
5696 case wScript3:
5697 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
5698 else def = defend(wpnId, power, edefSCRIPT);
5699 break;
5700
5701 case wScript4:
5702 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
5703 else def = defend(wpnId, power, edefSCRIPT);
5704 break;
5705
5706 case wScript5:
5707 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
5708 else def = defend(wpnId, power, edefSCRIPT);
5709 break;
5710
5711 case wScript6:
5712 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
5713 else def = defend(wpnId, power, edefSCRIPT);
5714 break;
5715
5716 case wScript7:
5717 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
5718 else def = defend(wpnId, power, edefSCRIPT);
5719 break;
5720
5721 case wScript8:
5722 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
5723 else def = defend(wpnId, power, edefSCRIPT);
5724 break;
5725
5726 case wScript9:
5727 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
5728 else def = defend(wpnId, power, edefSCRIPT);
5729 break;
5730
5731 case wScript10:
5732 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
5733 else def = defend(wpnId, power, edefSCRIPT);
5734 break;
5735
5736 case wWhistle:
5737 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
5738 else break;
5739 break;
5740
5741
5742 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
5743 //Probably best to do this from the qest file, loading the values of Script(generic) into each
5744 //of the ten if the quest version is lower than N.
5745 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
5746 //such as bool UseSeparatedScriptDefences. hah.
5747 default:
5748 //if(wpnId>=wScript1 && wpnId<=wScript10)
5749 // {
5750 // def = defend(wpnId, power, edefSCRIPT);
5751 // }
5752 // }
5753
5754 break;
5755 }
5756
5757 return def;
5758 }
5759
5760 // take damage or ignore it
5761 // -1: damage (if any) dealt
5762 // 1: blocked
5763 // 0: weapon passes through unhindered
5764 147753 int32_t enemy::takehit(weapon *w, weapon* realweap)
5765 {
5766
2/4
✓ Branch 0 taken 147753 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147753 times.
147753 if(fallclk||drownclk) return 0;
5767
2/2
✓ Branch 0 taken 32567 times.
✓ Branch 1 taken 115186 times.
147753 if(!realweap) realweap = w;
5768 147753 int32_t wpnId = w->id;
5769 147753 int32_t power = w->power;
5770 147753 int32_t wpnx = w->x;
5771 147753 int32_t wpny = w->y;
5772 147753 int32_t enemyHitWeapon = w->parentitem;
5773 int32_t wpnDir;
5774 147753 int32_t parent_item = w->parentitem;
5775
5776
1/2
✓ Branch 0 taken 147753 times.
✗ Branch 1 not taken.
147753 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5777 {
5778 wpnId = w->useweapon;
5779 }
5780
5781 // If it's a boomerang that just bounced, use the opposite direction;
5782 // otherwise, it might bypass a shield. This probably won't handle
5783 // every case correctly, but it's better than having shields simply
5784 // not work against boomerangs.
5785
8/8
✓ Branch 0 taken 17063 times.
✓ Branch 1 taken 130690 times.
✓ Branch 2 taken 10616 times.
✓ Branch 3 taken 6447 times.
✓ Branch 4 taken 10228 times.
✓ Branch 5 taken 388 times.
✓ Branch 6 taken 2514 times.
✓ Branch 7 taken 7714 times.
147753 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
5786 7714 wpnDir = oppositeDir[w->dir];
5787 else
5788 140039 wpnDir = w->dir;
5789
5790
5/8
✓ Branch 0 taken 147753 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147753 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147753 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2483 times.
✓ Branch 7 taken 148128 times.
147753 if(dying || clk<0 || hclk>0 || superman)
5791 2483 return 0;
5792
5793 //Prevent boomerang from writing to hitby[] for more than one frame.
5794 //This also prevents stunlock.
5795 //if ( stunclk > 0 ) return 0;
5796 //this needs a rule for boomerangs that cannot stunlock!
5797 //further, bouncing weapons should probably SFX_CHINK and bounce here.
5798 //sigh.
5799
5800 148128 int32_t ret = -1;
5801
5802 // This obscure quest rule...
5803
5/6
✓ Branch 0 taken 74548 times.
✓ Branch 1 taken 73580 times.
✓ Branch 2 taken 74420 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74420 times.
148128 if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
5804 {
5805 double _MSVC2022_tmp1, _MSVC2022_tmp2;
5806 128 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
5807 128 wpnDir=zc_oldrand()&3;
5808
5809
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 53 times.
128 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
5810 {
5811 53 wpnDir=down;
5812 53 }
5813
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 36 times.
75 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
5814 {
5815 36 wpnDir=right;
5816 36 }
5817
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 7 times.
39 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
5818 {
5819 7 wpnDir=up;
5820 7 }
5821 else
5822 {
5823 32 wpnDir=left;
5824 }
5825 128 }
5826
5827 148128 int32_t xdir = dir;
5828 148128 shieldCanBlock=false;
5829
5830 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
5831
4/4
✓ Branch 0 taken 146284 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 145878 times.
148922 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
5832
10/10
✓ Branch 0 taken 13331 times.
✓ Branch 1 taken 12925 times.
✓ Branch 2 taken 17937 times.
✓ Branch 3 taken 140866 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 140810 times.
✓ Branch 6 taken 982 times.
✓ Branch 7 taken 139828 times.
✓ Branch 8 taken 794 times.
✓ Branch 9 taken 139034 times.
146284 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
5833 )
5834 // The hammer should already be dealt with by subclasses (Walker etc.)
5835 {
5836
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 3678 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33100 switch(wpnId)
5837 {
5838 // Weapons which shields protect against
5839 case wSword:
5840 case wWand:
5841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3678 times.
3678 if(Hero.getCharging()>0)
5842 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
5843
5844 [[fallthrough]];
5845 case wHookshot:
5846 case wHSHandle:
5847 case wBrang:
5848 3941 shieldCanBlock=true;
5849 4193 break;
5850
5851 case wBeam:
5852 case wRefBeam:
5853 // Mirror shielded enemies!
5854 #if 0
5855 if(false /*flags2&guy_mirror*/ && !get_bit(quest_rules,qr_SWORDMIRROR))
5856 {
5857 if(wpnId>wEnemyWeapons)
5858 return 0;
5859
5860 sfx(WAV_CHINK,pan(int32_t(x)));
5861 return 1;
5862 }
5863
5864 #endif
5865
5866 [[fallthrough]];
5867 case wRefRock:
5868 case wRefFireball:
5869 case wMagic:
5870 #if 0
5871 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_bit(quest_rules,qr_REFLECTROCKS)))
5872 {
5873 sfx(WAV_CHINK,pan(int32_t(x)));
5874 return 3;
5875 }
5876
5877 #endif
5878
5879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 if(wpnId>wEnemyWeapons)
5880 return 0;
5881
5882 [[fallthrough]];
5883 default:
5884 1585 shieldCanBlock=true;
5885 1585 break;
5886
5887 // Bombs
5888 case wSBomb:
5889 case wBomb:
5890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_bit(quest_rules,qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
5891 else if (!get_bit(quest_rules,qr_BOMBSPIERCESHIELD))
5892 {
5893 sfx(WAV_CHINK,pan(int32_t(x)));
5894 return 0;
5895 }
5896 else break;
5897
5898 // Weapons which ignore shields
5899 case wWhistle:
5900 case wHammer:
5901 1 break;
5902
5903 // Weapons which shouldn't be removed by shields
5904 case wLitBomb:
5905 case wLitSBomb:
5906 case wWind:
5907 case wPhantom:
5908 case wSSparkle:
5909 case wBait:
5910 423 return 0;
5911
5912 case wFire:
5913 ;
5914 484 }
5915 6011 }
5916
5917
7/8
✓ Branch 0 taken 66681 times.
✓ Branch 1 taken 49014 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 17048 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
146889 switch(wpnId)
5918 {
5919 case wWhistle: //No longer completely ignore whistle weapons! -Z
5920 {
5921
5922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
5923 {
5924 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
5925 211 return 0; break;
5926 }
5927 else
5928 {
5929 w->power = power = itemsbuf[parent_item].misc5;
5930
5931 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5932
5933 if(def <= 0)
5934 {
5935 if ( def == -2 ) hp -= hp;
5936 else hp -= power;
5937 return def;
5938 }
5939 break;
5940 }
5941 break;
5942 }
5943
5944 case wPhantom:
5945 return 0;
5946
5947 case wLitBomb:
5948 case wLitSBomb:
5949 case wBait:
5950 case wWind:
5951 case wSSparkle:
5952 66681 return 0;
5953
5954 case wFSparkle:
5955
5956 // Only take sparkle damage if the sparkle's parent item is not
5957 // defended against.
5958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
5959 {
5960 11966 int32_t p = 0;
5961 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
5962
5963
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
5964 {
5965 case itype_arrow:
5966 if(!candamage(p, edefARROW, w->unblockable)) return 0;
5967
5968 break;
5969
5970 case itype_cbyrna:
5971 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
5972
5973 break;
5974
5975 case itype_brang:
5976
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
5977
5978 325 break;
5979
5980 default:
5981 return 0;
5982 }
5983 325 }
5984
5985 325 wpnId = wSword;
5986 325 power = game->get_hero_dmgmult()>>1;
5987 325 goto fsparkle;
5988 break;
5989
5990 case wBrang:
5991 {
5992 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
5993 17048 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5994 //preventing stunlock might be best, here. -Z
5995
2/2
✓ Branch 0 taken 4165 times.
✓ Branch 1 taken 12883 times.
17048 if(def >= 0) return def;
5996
5997 // Not hurt by 0-damage weapons
5998
2/2
✓ Branch 0 taken 2173 times.
✓ Branch 1 taken 10710 times.
12883 if(!(flags & guy_bhit))
5999 {
6000 10710 stunclk=160;
6001
6002
3/4
✓ Branch 0 taken 10710 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 9510 times.
10710 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
6003 {
6004
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
6005 1200 goto hitclock;
6006 }
6007
6008 9510 break;
6009 }
6010
6011
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1789 times.
2173 if(!power)
6012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1789 times.
1789 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
6013 else
6014 384 hp-=power;
6015
6016 2173 goto hitclock;
6017 }
6018
6019 case wHookshot:
6020 {
6021 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
6022 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
6023
6024
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
6025
6026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
6027
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
6028 {
6029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
6030 215 stunclk=160;
6031
6032
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
6033 {
6034 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
6035 goto hitclock;
6036 }
6037
6038 215 break;
6039 }
6040
6041
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
6042 else
6043 hp-=power;
6044
6045 6 goto hitclock;
6046 }
6047 break;
6048
6049 case wHSHandle:
6050 {
6051
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
6052 79 return 0;
6053
6054
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
6055
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
6056
6057 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
6058
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
6059
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
6060 334 return 0;
6061
6062 2182 power = game->get_hero_dmgmult();
6063 2507 }
6064
6065 fsparkle:
6066
6067 [[fallthrough]];
6068 default:
6069 // Work out the defenses!
6070 {
6071 49457 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
6072
6073
2/2
✓ Branch 0 taken 13168 times.
✓ Branch 1 taken 36289 times.
49457 if(def >= 0)
6074 13168 return def;
6075
2/2
✓ Branch 0 taken 36006 times.
✓ Branch 1 taken 283 times.
36289 else if(def == -2)
6076 {
6077 283 ret = 0;
6078 283 }
6079 }
6080
6081
2/2
✓ Branch 0 taken 36287 times.
✓ Branch 1 taken 2 times.
72578 if(!power)
6082 {
6083
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
6084 2 hp-=1;
6085 else
6086 {
6087 // Don't make a long chain of 'stun' hits
6088 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
6089 return 1;
6090
6091
6092 if(!switch_hooked)
6093 stunclk=160;
6094 break;
6095 }
6096 2 }
6097 36287 else hp-=power;
6098
6099 hitclock:
6100 39672 hclk=33;
6101
6102 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
6103
2/2
✓ Branch 0 taken 18464 times.
✓ Branch 1 taken 21208 times.
39672 if((dir&2)==(w->dir&2))
6104 {
6105 21208 sclk=(w->dir<<8)+16;
6106 21208 }
6107 39672 }
6108
6109
5/6
✓ Branch 0 taken 36514 times.
✓ Branch 1 taken 12883 times.
✓ Branch 2 taken 5440 times.
✓ Branch 3 taken 43957 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5440 times.
49397 if(((wpnId==wBrang) || (get_bit(quest_rules,qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
6110 {
6111 5440 fading=fade_blue_poof;
6112 5440 }
6113
6114
6/6
✓ Branch 0 taken 48394 times.
✓ Branch 1 taken 1003 times.
✓ Branch 2 taken 34319 times.
✓ Branch 3 taken 14075 times.
✓ Branch 4 taken 1441 times.
✓ Branch 5 taken 32878 times.
49397 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
6115 {
6116
1/2
✓ Branch 0 taken 2444 times.
✗ Branch 1 not taken.
2444 if( hitsfx > 0 ) //user-set hit sound.
6117 {
6118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2444 times.
2444 if (!dying) //don't play the hit sound on death! -Z
6119 2444 sfx(hitsfx, pan(int32_t(x)));
6120 2444 }
6121 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
6122 2444 }
6123 else //2.50.2 or earlier
6124 {
6125 46953 sfx(WAV_EHIT, pan(int32_t(x)));
6126 46953 sfx(hitsfx, pan(int32_t(x)));
6127 }
6128
2/2
✓ Branch 0 taken 49394 times.
✓ Branch 1 taken 3 times.
49397 if(family==eeGUY)
6129 3 sfx(WAV_EDEAD, pan(int32_t(x)));
6130
6131 // Penetrating weapons
6132
4/4
✓ Branch 0 taken 48659 times.
✓ Branch 1 taken 738 times.
✓ Branch 2 taken 43674 times.
✓ Branch 3 taken 5723 times.
49397 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
6133 {
6134 5723 int32_t item=enemyHitWeapon;
6135
6136
2/2
✓ Branch 0 taken 587 times.
✓ Branch 1 taken 5136 times.
5723 if(wpnId==wArrow)
6137 {
6138 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6139
5/6
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 91 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 426 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
587 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
6140 70 return 0;
6141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 517 times.
517 else if(get_bit(quest_rules,qr_ARROWS_ALWAYS_PENETRATE)) return 0;
6142 //if(item<0)
6143 else
6144 517 item=current_item_id(itype_arrow);
6145 517 }
6146
6147 else
6148 {
6149
6150 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6151
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5136 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
6152 return 0;
6153
6154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5136 times.
5136 else if(get_bit(quest_rules,qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
6155 else
6156 //if(item<0)
6157 5136 item=current_item_id(itype_sword);
6158 }
6159 5653 }
6160
6161 49327 return ret;
6162 148767 }
6163
6164 25909259 bool enemy::dont_draw()
6165 {
6166
6/6
✓ Branch 0 taken 25808490 times.
✓ Branch 1 taken 100769 times.
✓ Branch 2 taken 25737583 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 30972 times.
✓ Branch 5 taken 25777518 times.
25909259 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6167 131741 return true;
6168
6169
2/2
✓ Branch 0 taken 225193 times.
✓ Branch 1 taken 25552325 times.
25777518 if(flags&guy_invisible)
6170 225193 return true;
6171
6172
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 25551893 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
25552325 if(flags&lens_only && !lensclk)
6173 return true;
6174
6175
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 25506374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
25552325 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
6176 !((flags&lens_only) && (get_bit(quest_rules,qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
6177 return true;
6178
6179 25552325 return false;
6180 25909259 }
6181
6182 #define DRAW_NORMAL 2
6183 #define DRAW_CLOAKED 1
6184 #define DRAW_INVIS 0
6185 // base drawing function to be used by all derived classes instead of
6186 // sprite::draw()
6187 22769908 void enemy::draw(BITMAP *dest)
6188 {
6189
6/6
✓ Branch 0 taken 22421919 times.
✓ Branch 1 taken 347989 times.
✓ Branch 2 taken 22339269 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 150759 times.
✓ Branch 5 taken 22271160 times.
22769908 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6190 498748 return;
6191
2/2
✓ Branch 0 taken 1523860 times.
✓ Branch 1 taken 20747300 times.
22271160 if(flags&guy_invisible)
6192 1523860 return;
6193
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 20721042 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20747300 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
6194 return;
6195
6196 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
6197 // be cloaked if they have "invisible displays as cloaked" checked.
6198
6199 20747300 byte canSee = DRAW_NORMAL;
6200 //Enemy specific stuff
6201
1/2
✓ Branch 0 taken 20747300 times.
✗ Branch 1 not taken.
20747300 if ( editorflags & ENEMY_FLAG1 )
6202 {
6203 canSee = DRAW_INVIS;
6204 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
6205 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
6206 {
6207 if (game->item[dmisc13])
6208 {
6209 canSee = DRAW_NORMAL;
6210 }
6211 //else if ( lensclk && getlensid.flags SHOWINVIS )
6212 //{
6213 //
6214 //}
6215 //else
6216 //{
6217 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
6218 // //otherwisem invisible
6219 //}
6220 }
6221 }
6222 //Room specific
6223
2/2
✓ Branch 0 taken 20556655 times.
✓ Branch 1 taken 190645 times.
20747300 if (tmpscr->flags3&fINVISROOM)
6224 {
6225
4/6
✓ Branch 0 taken 190645 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32460 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 32460 times.
223105 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
6226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32460 times.
32460 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
6227 190645 }
6228 //Lens check
6229
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 20721042 times.
20747300 if (lensclk)
6230 {
6231
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
6232 {
6233 if (canSee == DRAW_NORMAL)
6234 {
6235 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
6236 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
6237 }
6238 }
6239
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
6240 {
6241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
6242 432 }
6243 26258 }
6244 else
6245 {
6246
2/2
✓ Branch 0 taken 20647626 times.
✓ Branch 1 taken 73416 times.
20721042 if(flags&lens_only)
6247 73416 canSee = DRAW_INVIS;
6248 }
6249
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 20673884 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
20747300 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
6250
3/4
✓ Branch 0 taken 20641424 times.
✓ Branch 1 taken 105876 times.
✓ Branch 2 taken 20641424 times.
✗ Branch 3 not taken.
20747300 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
6251
6252
2/2
✓ Branch 0 taken 20673884 times.
✓ Branch 1 taken 73416 times.
20747300 if (canSee == DRAW_INVIS)
6253 73416 return;
6254
6255
3/4
✓ Branch 0 taken 20673742 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20673742 times.
20673884 if(fallclk||drownclk)
6256 {
6257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
6258 {
6259 sprite::drawcloaked(dest);
6260 }
6261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
6262 {
6263 142 sprite::draw(dest);
6264 142 }
6265 142 return;
6266 }
6267 20673742 int32_t cshold=cs;
6268
6269
2/2
✓ Branch 0 taken 471563 times.
✓ Branch 1 taken 20202179 times.
20673742 if(dying)
6270 {
6271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471563 times.
471563 if(clk2>=19)
6272 {
6273 if(!(clk2&2))
6274 {
6275 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
6276 if (canSee == DRAW_CLOAKED)
6277 {
6278 sprite::drawcloaked(dest);
6279 }
6280 else if (canSee == DRAW_NORMAL)
6281 {
6282 sprite::draw(dest);
6283 }
6284 }
6285 return;
6286 }
6287
6288 471563 flip = 0;
6289 471563 tile = wpnsbuf[spr_death].tile;
6290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 471563 times.
471563 if ( do_animation )
6291 {
6292 471563 int32_t offs = 0;
6293
2/2
✓ Branch 0 taken 466756 times.
✓ Branch 1 taken 4807 times.
471563 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6294 {
6295
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
6296 {
6297 239 spr_death_anim_clk=0;
6298 239 clk2=1;
6299
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
6300 235 death_sfx();
6301 239 }
6302
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
6303 {
6304 4456 ++clk2;
6305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6306
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm *= zc_max(1,txsz);
6307 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6308
2/2
✓ Branch 0 taken 4382 times.
✓ Branch 1 taken 74 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6309
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 4217 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6310 {
6311 239 spr_death_anim_clk=-1;
6312 239 clk2=1;
6313 239 }
6314 4456 }
6315 4807 tile += spr_death_anim_frm;
6316 4807 }
6317
2/2
✓ Branch 0 taken 19363 times.
✓ Branch 1 taken 447393 times.
466756 else if(BSZ)
6318 {
6319
2/2
✓ Branch 0 taken 15226 times.
✓ Branch 1 taken 4137 times.
19363 offs = zc_min((15-clk2)/3,4);
6320 19363 }
6321
4/4
✓ Branch 0 taken 298304 times.
✓ Branch 1 taken 149089 times.
✓ Branch 2 taken 148991 times.
✓ Branch 3 taken 149313 times.
447393 else if(clk2>6 && clk2<=12)
6322 {
6323 149313 offs = 1;
6324 149313 }
6325
6326
2/2
✓ Branch 0 taken 305669 times.
✓ Branch 1 taken 165894 times.
471563 if(offs)
6327 {
6328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165894 times.
165894 offs *= zc_max(1,txsz);
6329 165894 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
6330
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 165846 times.
165894 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6331 165894 }
6332 471563 tile += offs;
6333 471563 }
6334
6335
6/6
✓ Branch 0 taken 466756 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447393 times.
✓ Branch 3 taken 19363 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318339 times.
471563 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6336 153224 cs = wpnsbuf[spr_death].csets&15;
6337 else
6338 318339 cs = (((clk2+5)>>1)&3)+6;
6339 471563 }
6340
3/4
✓ Branch 0 taken 629119 times.
✓ Branch 1 taken 19573060 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 629119 times.
20202179 else if(hclk>0 && getCanFlicker())
6341 {
6342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 629119 times.
629119 if(family==eeGANON)
6343 cs=(((hclk-1)>>1)&3)+6;
6344
4/4
✓ Branch 0 taken 582229 times.
✓ Branch 1 taken 46890 times.
✓ Branch 2 taken 174018 times.
✓ Branch 3 taken 408211 times.
629119 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6345 408211 cs=(((hclk-1)>>1)&3)+6;
6346 629119 }
6347 //draw every other frame for flickering enemies
6348
8/10
✓ Branch 0 taken 10329018 times.
✓ Branch 1 taken 10344724 times.
✓ Branch 2 taken 10329018 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 539804 times.
✓ Branch 5 taken 9789214 times.
✓ Branch 6 taken 137003 times.
✓ Branch 7 taken 402801 times.
✓ Branch 8 taken 137003 times.
✗ Branch 9 not taken.
20673742 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER) && getCanFlicker()))
6349 {
6350
2/2
✓ Branch 0 taken 32289 times.
✓ Branch 1 taken 20504450 times.
20536739 if (canSee == DRAW_CLOAKED)
6351 {
6352 32289 sprite::drawcloaked(dest);
6353 32289 }
6354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20504450 times.
20504450 else if (canSee == DRAW_NORMAL)
6355 {
6356
1/2
✓ Branch 0 taken 20504450 times.
✗ Branch 1 not taken.
20504450 if ( frozenclock < 0 )
6357 {
6358 if ( frozentile > 0 ) tile = frozentile;
6359 loadpalset(csBOSS,frozencset);
6360 }
6361 20504450 sprite::draw(dest);
6362 20504450 }
6363 20536739 }
6364 20673742 cs=cshold;
6365 22769908 }
6366
6367 //old zc bosses
6368 21157531 void enemy::drawzcboss(BITMAP *dest)
6369 {
6370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21157531 times.
21157531 if(dont_draw())
6371 return;
6372
6373 21157531 int32_t cshold=cs;
6374
6375
2/2
✓ Branch 0 taken 432445 times.
✓ Branch 1 taken 20725086 times.
21157531 if(dying)
6376 {
6377
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 429853 times.
432445 if(clk2>=19)
6378 {
6379
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
6380 1296 sprite::drawzcboss(dest);
6381
6382 2592 return;
6383 }
6384
6385 429853 flip = 0;
6386 429853 tile = wpnsbuf[spr_death].tile;
6387
6388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 429853 times.
429853 if ( do_animation )
6389 {
6390
2/2
✓ Branch 0 taken 427667 times.
✓ Branch 1 taken 2186 times.
429853 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6391 {
6392
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
6393 {
6394 2 spr_death_anim_clk=0;
6395 2 clk2=1;
6396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
6397 2 death_sfx();
6398 2 }
6399
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
6400 {
6401 2 ++clk2;
6402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6403
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm *= zc_max(1,txsz);
6404 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6405
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6406
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6407 {
6408 spr_death_anim_clk=-1;
6409 clk2=1;
6410 }
6411 2 }
6412 2186 tile += spr_death_anim_frm;
6413 2186 }
6414
2/2
✓ Branch 0 taken 19363 times.
✓ Branch 1 taken 408304 times.
427667 else if(BSZ)
6415
2/2
✓ Branch 0 taken 15226 times.
✓ Branch 1 taken 4137 times.
19363 tile += zc_min((15-clk2)/3,4);
6416
4/4
✓ Branch 0 taken 272130 times.
✓ Branch 1 taken 136174 times.
✓ Branch 2 taken 135930 times.
✓ Branch 3 taken 136200 times.
408304 else if(clk2>6 && clk2<=12)
6417 136200 ++tile;
6418 429853 }
6419
6420
6/6
✓ Branch 0 taken 427667 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408304 times.
✓ Branch 3 taken 19363 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282400 times.
429853 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6421 147453 cs = wpnsbuf[spr_death].csets&15;
6422 else
6423 282400 cs = (((clk2+5)>>1)&3)+6;
6424 429853 }
6425
2/2
✓ Branch 0 taken 20096677 times.
✓ Branch 1 taken 628409 times.
20725086 else if(hclk>0)
6426 {
6427
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 625817 times.
628409 if(family==eeGANON)
6428 2592 cs=(((hclk-1)>>1)&3)+6;
6429
4/4
✓ Branch 0 taken 584144 times.
✓ Branch 1 taken 41673 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 473679 times.
625817 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6430 473679 cs=(((hclk-1)>>1)&3)+6;
6431 628409 }
6432
6433
2/4
✓ Branch 0 taken 164652 times.
✓ Branch 1 taken 20990287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
21154939 if((tmpscr->flags3&fINVISROOM) &&
6434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 164652 times.
164652 !(current_item(itype_amulet)) &&
6435 !(get_bit(quest_rules,qr_LENSSEESENEMIES) &&
6436 lensclk) && family!=eeGANON)
6437 {
6438 sprite::drawcloaked(dest);
6439 }
6440 else
6441 {
6442
6/6
✓ Branch 0 taken 21135123 times.
✓ Branch 1 taken 19816 times.
✓ Branch 2 taken 1031552 times.
✓ Branch 3 taken 20103571 times.
✓ Branch 4 taken 872047 times.
✓ Branch 5 taken 159505 times.
21154939 if(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER))
6443 {
6444
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
6445 143685 sprite::drawzcboss(dest);
6446 159505 }
6447 else
6448 20995434 sprite::drawzcboss(dest);
6449 }
6450
6451 21154939 cs=cshold;
6452 21157531 }
6453
6454
6455 // similar to the overblock function--can do up to a 32x32 sprite
6456 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
6457 129329 void enemy::drawblock(BITMAP *dest,int32_t mask)
6458 {
6459 129329 int32_t thold=tile;
6460 129329 int32_t t1=tile;
6461 129329 int32_t t2=tile+20;
6462 129329 int32_t t3=tile+1;
6463 129329 int32_t t4=tile+21;
6464
6465
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 129329 times.
129329 switch(mask)
6466 {
6467 case 1:
6468 enemy::drawzcboss(dest);
6469 break;
6470
6471 case 3:
6472 if(flip&2)
6473 zc_swap(t1,t2);
6474
6475 tile=t1;
6476 enemy::drawzcboss(dest);
6477 tile=t2;
6478 yofs+=16;
6479 enemy::drawzcboss(dest);
6480 yofs-=16;
6481 break;
6482
6483 case 5:
6484 t2=tile+1;
6485
6486 if(flip&1)
6487 zc_swap(t1,t2);
6488
6489 tile=t1;
6490 enemy::drawzcboss(dest);
6491 tile=t2;
6492 xofs+=16;
6493 enemy::drawzcboss(dest);
6494 xofs-=16;
6495 break;
6496
6497 case 15:
6498
2/2
✓ Branch 0 taken 123216 times.
✓ Branch 1 taken 6113 times.
129329 if(flip&1)
6499 {
6500 6113 zc_swap(t1,t3);
6501 6113 zc_swap(t2,t4);
6502 6113 }
6503
6504
1/2
✓ Branch 0 taken 129329 times.
✗ Branch 1 not taken.
129329 if(flip&2)
6505 {
6506 zc_swap(t1,t2);
6507 zc_swap(t3,t4);
6508 }
6509
6510 129329 tile=t1;
6511 129329 enemy::drawzcboss(dest);
6512 129329 tile=t2;
6513 129329 yofs+=16;
6514 129329 enemy::drawzcboss(dest);
6515 129329 yofs-=16;
6516 129329 tile=t3;
6517 129329 xofs+=16;
6518 129329 enemy::drawzcboss(dest);
6519 129329 tile=t4;
6520 129329 yofs+=16;
6521 129329 enemy::drawzcboss(dest);
6522 129329 xofs-=16;
6523 129329 yofs-=16;
6524 129329 break;
6525 }
6526
6527 129329 tile=thold;
6528 129329 }
6529
6530 4531771 void enemy::drawshadow(BITMAP *dest, bool translucent)
6531 {
6532
4/4
✓ Branch 0 taken 4174837 times.
✓ Branch 1 taken 356934 times.
✓ Branch 2 taken 419689 times.
✓ Branch 3 taken 3755148 times.
4531771 if(dont_draw() || isSideViewGravity())
6533 {
6534 776623 return;
6535 }
6536
6537
2/2
✓ Branch 0 taken 63093 times.
✓ Branch 1 taken 3692055 times.
3755148 if(dying)
6538 {
6539 63093 return;
6540 }
6541
6542
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3692055 times.
✓ Branch 2 taken 145552 times.
✓ Branch 3 taken 3546503 times.
3692055 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
6543 3692055 (darkroom))
6544 {
6545 145552 return;
6546 }
6547 else
6548 {
6549
4/4
✓ Branch 0 taken 3408891 times.
✓ Branch 1 taken 137612 times.
✓ Branch 2 taken 3399809 times.
✓ Branch 3 taken 9082 times.
3546503 if(enemycanfall(id, false) && shadowtile == 0)
6550 9082 shadowtile = wpnsbuf[spr_shadow].tile;
6551
6552
5/6
✓ Branch 0 taken 2974453 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 2974453 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2836841 times.
✓ Branch 5 taken 137612 times.
3546503 if(z>0 || fakez>0 || !enemycanfall(id, false))
6553 {
6554
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 709546 times.
709662 if(!shadow_overpit(this))
6555 709546 sprite::drawshadow(dest,translucent);
6556 709662 }
6557 }
6558 4531771 }
6559
6560 80451 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
6561 {
6562 80451 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
6563
6564
1/2
✓ Branch 0 taken 80451 times.
✗ Branch 1 not taken.
80451 if(sub!=NULL)
6565 {
6566 80451 xofs-=mx;
6567 80451 yofs-=my;
6568 80451 enemy::draw(sub);
6569 80451 xofs+=mx;
6570 80451 yofs+=my;
6571 80451 destroy_bitmap(sub);
6572 80451 }
6573 else
6574 enemy::draw(dest);
6575 80451 }
6576
6577 // override hit detection to check for invicibility, stunned, etc
6578 61448118 bool enemy::hit()
6579 {
6580
4/4
✓ Branch 0 taken 60783761 times.
✓ Branch 1 taken 664357 times.
✓ Branch 2 taken 59760856 times.
✓ Branch 3 taken 1022905 times.
61448118 if(dying || hclk>0) return false;
6581 59760856 return sprite::hit();
6582 61448118 }
6583 52704 bool enemy::hit(sprite *s)
6584 {
6585
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
6586 52264 return sprite::hit(s);
6587 52704 }
6588
6589 25311062 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
6590 {
6591
2/2
✓ Branch 0 taken 1972400 times.
✓ Branch 1 taken 23338662 times.
25311062 if(!hit()) return false;
6592 23338662 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
6593 25311062 }
6594 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
6595 {
6596 if(!hit()) return false;
6597 return sprite::hit(tx,ty,txsz2,tysz2);
6598 }
6599
6600 6635680 bool enemy::hit(weapon *w)
6601 {
6602
2/2
✓ Branch 0 taken 623933 times.
✓ Branch 1 taken 6011747 times.
6635680 if(!hit()) return false;
6603
2/4
✓ Branch 0 taken 6011747 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6011747 times.
6011747 if(replay_is_active() && replay_get_version() < 14)
6604 {
6605
4/6
✓ Branch 0 taken 5944951 times.
✓ Branch 1 taken 66796 times.
✓ Branch 2 taken 5944951 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5944951 times.
✗ Branch 5 not taken.
6011747 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
6606 66796 return false;
6607 5944951 return sprite::hit(w);
6608 }
6609 return w->hit(this);
6610 6635680 }
6611
6612 5590507 bool enemy::can_pitfall(bool checkspawning)
6613 {
6614
4/4
✓ Branch 0 taken 5583716 times.
✓ Branch 1 taken 6791 times.
✓ Branch 2 taken 5580710 times.
✓ Branch 3 taken 9797 times.
5590507 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
6615
2/2
✓ Branch 0 taken 5573647 times.
✓ Branch 1 taken 7063 times.
5580710 switch(guysbuf[id&0xFFF].family)
6616 {
6617 case eeAQUA:
6618 case eeDIG:
6619 case eeDONGO:
6620 case eeFAIRY:
6621 case eeGANON:
6622 case eeGHOMA:
6623 case eeGLEEOK:
6624 case eeGUY:
6625 case eeLANM:
6626 case eeMANHAN:
6627 case eeMOLD:
6628 case eeNONE:
6629 case eePATRA:
6630 case eeZORA:
6631 7063 return false; //Disallowed types
6632 default:
6633 5573647 return true;
6634 }
6635 5590507 }
6636 //Handle death
6637 19303891 void enemy::try_death(bool force_kill)
6638 {
6639
8/8
✓ Branch 0 taken 19291561 times.
✓ Branch 1 taken 12330 times.
✓ Branch 2 taken 19291559 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 20912 times.
✓ Branch 5 taken 19270647 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 20911 times.
19303891 if(!dying && (force_kill || (hp<=0 && !immortal)))
6640 {
6641 20913 std::vector<int32_t> &ev = FFCore.eventData;
6642 20913 ev.clear();
6643 20913 ev.push_back(10000);
6644 20913 ev.push_back(getUID());
6645
6646 20913 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
6647 20913 bool isSaved = !ev[0];
6648 20913 ev.clear();
6649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20913 times.
20913 if(isSaved) return;
6650
6651
4/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 20890 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 21 times.
20913 if(itemguy && (hasitem&2)!=0)
6652 {
6653
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 21 times.
45 for(int32_t i=0; i<items.Count(); i++)
6654 {
6655
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 21 times.
24 if(((item*)items.spr(i))->pickup&ipENEMY)
6656 {
6657
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
6658 {
6659 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
6660 {
6661 items.spr(i)->x = x+hxofs+(hxsz/2)-8;
6662 items.spr(i)->y = y+hyofs+(hysz/2)-10-fakez;
6663 }
6664 else
6665 {
6666 if(extend >= 3)
6667 {
6668 items.spr(i)->x = x+(txsz-1)*8;
6669 items.spr(i)->y = y-2+(tysz-1)*8;
6670 }
6671 else
6672 {
6673 items.spr(i)->x = x;
6674 items.spr(i)->y = y - 2;
6675 }
6676 }
6677 items.spr(i)->z = z;
6678 items.spr(i)->fakez = fakez;
6679 }
6680 else
6681 {
6682 21 items.spr(i)->x = x;
6683 21 items.spr(i)->y = y - 2;
6684 }
6685 21 }
6686 24 }
6687 21 }
6688
6689 20913 dying=true;
6690
6691
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 20891 times.
20913 if(fading==fade_flash_die)
6692 22 clk2=19+18*4;
6693 else
6694 {
6695 20891 clk2 = BSZ ? 15 : 19;
6696
6697
2/2
✓ Branch 0 taken 5405 times.
✓ Branch 1 taken 15486 times.
20891 if(fading!=fade_blue_poof)
6698 15486 fading=0;
6699 }
6700
6701
2/2
✓ Branch 0 taken 20890 times.
✓ Branch 1 taken 23 times.
20913 if(itemguy)
6702 {
6703 23 hasitem&=~2;
6704 23 item_set=0;
6705 23 }
6706
6707
6/6
✓ Branch 0 taken 20229 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 15999 times.
✓ Branch 3 taken 4230 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 15881 times.
20913 if(currscr<128 && count_enemy && !script_spawned)
6708 15881 game->guys[(currmap<<7)+currscr]-=1;
6709 20913 }
6710 19303891 }
6711
6712 // --==**==--
6713
6714 // Movement routines that can be used by derived classes as needed
6715
6716 // --==**==--
6717
6718 304036 void enemy::fix_coords(bool bound)
6719 {
6720
1/2
✓ Branch 0 taken 304036 times.
✗ Branch 1 not taken.
304036 if ((get_bit(quest_rules,qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
6721
1/2
✓ Branch 0 taken 304036 times.
✗ Branch 1 not taken.
304036 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
6722
6723
6724
2/2
✓ Branch 0 taken 40585 times.
✓ Branch 1 taken 263451 times.
304036 if(bound)
6725 {
6726
1/2
✓ Branch 0 taken 263451 times.
✗ Branch 1 not taken.
263451 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
6727 {
6728
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 263451 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
263451 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
6729
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 263451 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
263451 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
6730 263451 }
6731 else
6732 {
6733 x=vbound(x, 0,240);
6734 y=vbound(y, 0,160);
6735 }
6736 263451 }
6737
6738
6/10
✓ Branch 0 taken 302521 times.
✓ Branch 1 taken 1515 times.
✓ Branch 2 taken 304036 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304036 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304036 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 304036 times.
304036 if(!OUTOFBOUNDS)
6739 {
6740 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
6741
6742 if(isSideViewGravity())
6743 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
6744 else
6745 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
6746 */
6747 304036 do_fix(x, 16, true);
6748
2/2
✓ Branch 0 taken 1515 times.
✓ Branch 1 taken 302521 times.
304036 if(isSideViewGravity())
6749 1515 do_fix(y,8,true);
6750 302521 else do_fix(y,16,true);
6751 304036 }
6752 304036 }
6753 5964 bool enemy::cannotpenetrate()
6754 {
6755
4/4
✓ Branch 0 taken 5850 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5831 times.
5964 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
6756 }
6757
6758 375 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6759 {
6760 bool ok;
6761 375 int32_t dx = 0, dy = 0;
6762 375 int32_t sv = 8;
6763
6764 //Why is this here??? Why is it needed???
6765 375 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6766
6767
8/9
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 65 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 53 times.
✗ Branch 8 not taken.
375 switch(ndir)
6768 {
6769 case 8:
6770 case up:
6771
3/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
43 if(canfall(id) && isSideViewGravity())
6772 return false;
6773
6774 43 dy = dy1-s;
6775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 special = (special==spw_clipbottomright)?spw_none:special;
6776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6777 43 break;
6778
6779 case 12:
6780 case down:
6781
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
37 if(canfall(id) && isSideViewGravity())
6782 return false;
6783
6784 37 dy = dy2+s;
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6786 37 break;
6787
6788 case 14:
6789 case left:
6790 30 dx = dx1-s;
6791 30 sv = ((isSideViewGravity())?7:8);
6792
2/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
30 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6793
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 29 times.
30 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6794 30 break;
6795
6796 case 10:
6797 case right:
6798 49 dx = dx2+s;
6799 49 sv = ((isSideViewGravity())?7:8);
6800
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 45 times.
49 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6801 49 break;
6802
6803 case 9:
6804 case r_up:
6805 65 dx = dx2+s;
6806 65 dy = dy1-s;
6807
3/4
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 1 times.
129 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6809 65 break;
6810
6811 case 11:
6812 case r_down:
6813 56 dx = dx2+s;
6814 56 dx = dy2+s;
6815
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6817 56 break;
6818
6819 case 13:
6820 case l_down:
6821 42 dx = dx1-s;
6822 42 dy = dy2+s;
6823
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
82 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6825 42 break;
6826
6827 case 15:
6828 case l_up:
6829 53 dx = dx1-s;
6830 53 dy = dy1-s;
6831
2/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
106 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6833 53 break;
6834
6835 default:
6836 db=99;
6837 return true;
6838 }
6839
6840 375 return ok;
6841 375 }
6842
6843
6844
6845
6846 // returns true if next step is ok, false if there is something there
6847 3495563 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
6848 {
6849 3495563 bool ok = false; //initialise the var, son't just declare it
6850 3495563 int32_t dx = 0, dy = 0;
6851 3495563 int32_t sv = 8;
6852 3495563 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
6853 //Why is this here??? Why is it needed???
6854 3495563 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3495563 times.
3495563 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
6856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3495563 times.
3495563 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
6857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3495563 times.
3495563 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
6858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3495563 times.
3495563 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
6859 3495563 bool offgrid = OFFGRID_ENEMY;
6860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3495563 times.
3495563 if(!offgrid)
6861 {
6862 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
6863
1/2
✓ Branch 0 taken 3495563 times.
✗ Branch 1 not taken.
3495563 if(usehei<16)usehei=16;
6864
1/2
✓ Branch 0 taken 3495563 times.
✗ Branch 1 not taken.
3495563 if(usewid<16)usewid=16;
6865 3495563 }
6866
9/9
✓ Branch 0 taken 646476 times.
✓ Branch 1 taken 518798 times.
✓ Branch 2 taken 580898 times.
✓ Branch 3 taken 586816 times.
✓ Branch 4 taken 264971 times.
✓ Branch 5 taken 320258 times.
✓ Branch 6 taken 295401 times.
✓ Branch 7 taken 280852 times.
✓ Branch 8 taken 1093 times.
3495563 switch(ndir) //need to check every 8 pixels between two points
6867 {
6868 case 8:
6869 case up:
6870 {
6871
4/4
✓ Branch 0 taken 96071 times.
✓ Branch 1 taken 550405 times.
✓ Branch 2 taken 95345 times.
✓ Branch 3 taken 726 times.
646476 if(enemycanfall(id) && isSideViewGravity())
6872 726 return false;
6873
6874 645750 dy = dy1-s;
6875
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 645747 times.
645750 special = (special==spw_clipbottomright)?spw_none:special;
6876 645750 tries = usewid/(offgrid ? 8 : 16);
6877 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6878
2/2
✓ Branch 0 taken 553637 times.
✓ Branch 1 taken 645750 times.
1199387 for ( ; tries > 0; --tries )
6879 {
6880
2/2
✓ Branch 0 taken 90449 times.
✓ Branch 1 taken 555301 times.
645750 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
6881 645750 try_x += (offgrid ? 8 : 16);
6882
2/2
✓ Branch 0 taken 553637 times.
✓ Branch 1 taken 92113 times.
645750 if (!ok) break;
6883 553637 }
6884
2/2
✓ Branch 0 taken 553637 times.
✓ Branch 1 taken 92113 times.
645750 if(!ok) break;
6885
1/2
✓ Branch 0 taken 553637 times.
✗ Branch 1 not taken.
553637 if((usewid%16)>0) //Uneven width
6886 {
6887 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
6888 }
6889 553637 break;
6890 }
6891 case 12:
6892 case down:
6893 {
6894
4/4
✓ Branch 0 taken 106704 times.
✓ Branch 1 taken 412094 times.
✓ Branch 2 taken 105898 times.
✓ Branch 3 taken 806 times.
518798 if(enemycanfall(id) && isSideViewGravity())
6895 806 return false;
6896
6897 517992 dy = dy2+s;
6898 517992 tries = usewid/(offgrid ? 8 : 16);
6899 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6900
2/2
✓ Branch 0 taken 422309 times.
✓ Branch 1 taken 517992 times.
940301 for ( ; tries > 0; --tries )
6901 {
6902
3/4
✓ Branch 0 taken 95461 times.
✓ Branch 1 taken 422531 times.
✓ Branch 2 taken 422531 times.
✗ Branch 3 not taken.
517992 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6903 517992 try_x += (offgrid ? 8 : 16);
6904
2/2
✓ Branch 0 taken 422309 times.
✓ Branch 1 taken 95683 times.
517992 if (!ok) break;
6905 422309 }
6906
2/2
✓ Branch 0 taken 422309 times.
✓ Branch 1 taken 95683 times.
517992 if(!ok) break;
6907
1/2
✓ Branch 0 taken 422309 times.
✗ Branch 1 not taken.
422309 if((usewid%16)>0) //Uneven width
6908 {
6909 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6910 }
6911 422309 break;
6912 }
6913 case 14:
6914 case left:
6915 {
6916 580898 dx = dx1-s;
6917 580898 sv = ((isSideViewGravity())?7:0);
6918
4/4
✓ Branch 0 taken 580892 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1251 times.
✓ Branch 3 taken 579641 times.
580898 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6919 580898 tries = usehei/(offgrid ? 8 : 16);
6920 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6921
2/2
✓ Branch 0 taken 491525 times.
✓ Branch 1 taken 580898 times.
1072423 for ( ; tries > 0; --tries )
6922 {
6923
2/2
✓ Branch 0 taken 88799 times.
✓ Branch 1 taken 492099 times.
580898 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
6924 580898 try_y += (offgrid ? 8 : 16);
6925
2/2
✓ Branch 0 taken 491525 times.
✓ Branch 1 taken 89373 times.
580898 if (!ok) break;
6926 491525 }
6927
2/2
✓ Branch 0 taken 491525 times.
✓ Branch 1 taken 89373 times.
580898 if(!ok) break;
6928
1/2
✓ Branch 0 taken 491525 times.
✗ Branch 1 not taken.
491525 if((usehei%16)>0) //Uneven height
6929 {
6930 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
6931 }
6932 491525 break;
6933 }
6934 case 10:
6935 case right:
6936 {
6937 586816 dx = dx2+s;
6938 586816 sv = ((isSideViewGravity())?7:0);
6939 586816 tries = usehei/(offgrid ? 8 : 16);
6940 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6941
2/2
✓ Branch 0 taken 499807 times.
✓ Branch 1 taken 586816 times.
1086623 for ( ; tries > 0; --tries )
6942 {
6943
3/4
✓ Branch 0 taken 86437 times.
✓ Branch 1 taken 500379 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 500379 times.
586816 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
6944 586816 try_y += (offgrid ? 8 : 16);
6945
2/2
✓ Branch 0 taken 499807 times.
✓ Branch 1 taken 87009 times.
586816 if (!ok) break;
6946 499807 }
6947
2/2
✓ Branch 0 taken 499807 times.
✓ Branch 1 taken 87009 times.
586816 if(!ok) break;
6948
1/2
✓ Branch 0 taken 499807 times.
✗ Branch 1 not taken.
499807 if((usehei%16)>0) //Uneven height
6949 {
6950 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
6951 }
6952 499807 break;
6953 }
6954 case 9:
6955 case r_up:
6956 {
6957 264971 dx = dx2+s;
6958 264971 dy = dy1-s;
6959 264971 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6960 264971 sv = ((isSideViewGravity())?7:0);
6961
2/2
✓ Branch 0 taken 256302 times.
✓ Branch 1 taken 264971 times.
521273 for ( ; tries_x > 0; --tries_x )
6962 {
6963 264971 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6964 264971 try_y = 0;
6965
2/2
✓ Branch 0 taken 256302 times.
✓ Branch 1 taken 264971 times.
521273 for ( ; tries_y > 0; --tries_y )
6966 {
6967
4/4
✓ Branch 0 taken 261306 times.
✓ Branch 1 taken 3665 times.
✓ Branch 2 taken 258460 times.
✓ Branch 3 taken 2846 times.
523431 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6968
2/2
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 256861 times.
258460 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6969 264971 try_y += (offgrid ? 8 : 16);
6970
2/2
✓ Branch 0 taken 256302 times.
✓ Branch 1 taken 8669 times.
264971 if (!ok) break;
6971 256302 }
6972
2/2
✓ Branch 0 taken 256302 times.
✓ Branch 1 taken 8669 times.
264971 if (!ok) break;
6973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256302 times.
256302 if((usehei%16)>0) //Uneven height
6974 {
6975 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6976 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6977 }
6978 256302 try_x += (offgrid ? 8 : 16);
6979 256302 }
6980
2/2
✓ Branch 0 taken 256302 times.
✓ Branch 1 taken 8669 times.
264971 if(!ok) break;
6981
1/2
✓ Branch 0 taken 256302 times.
✗ Branch 1 not taken.
256302 if((usewid%16)>0) //Uneven width
6982 {
6983 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6984 try_y = 0;
6985 for ( ; tries_y > 0; --tries_y )
6986 {
6987 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6988 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6989 try_y += (offgrid ? 8 : 16);
6990 if (!ok) break;
6991 }
6992 if (!ok) break;
6993 if((usehei%16)>0) //Uneven height
6994 {
6995 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6996 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6997 }
6998 }
6999 256302 break;
7000 }
7001 case 11:
7002 case r_down:
7003 {
7004 320258 dx = dx2+s;
7005 320258 dx = dy2+s;
7006 320258 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7007 //sv = ((isSideViewGravity())?7:0);
7008
2/2
✓ Branch 0 taken 313037 times.
✓ Branch 1 taken 320258 times.
633295 for ( ; tries_x > 0; --tries_x )
7009 {
7010 320258 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7011 320258 try_y = 0;
7012
2/2
✓ Branch 0 taken 313037 times.
✓ Branch 1 taken 320258 times.
633295 for ( ; tries_y > 0; --tries_y )
7013 {
7014
4/4
✓ Branch 0 taken 320126 times.
✓ Branch 1 taken 132 times.
✓ Branch 2 taken 313298 times.
✓ Branch 3 taken 6828 times.
633556 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7015
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 313260 times.
313298 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7016 320258 try_y += (offgrid ? 8 : 16);
7017
2/2
✓ Branch 0 taken 313037 times.
✓ Branch 1 taken 7221 times.
320258 if (!ok) break;
7018 313037 }
7019
2/2
✓ Branch 0 taken 313037 times.
✓ Branch 1 taken 7221 times.
320258 if (!ok) break;
7020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313037 times.
313037 if((usehei%16)>0) //Uneven height
7021 {
7022 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7023 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7024 }
7025 313037 try_x += (offgrid ? 8 : 16);
7026 313037 }
7027
2/2
✓ Branch 0 taken 313037 times.
✓ Branch 1 taken 7221 times.
320258 if(!ok) break;
7028
1/2
✓ Branch 0 taken 313037 times.
✗ Branch 1 not taken.
313037 if((usewid%16)>0) //Uneven width
7029 {
7030 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7031 try_y = 0;
7032 for ( ; tries_y > 0; --tries_y )
7033 {
7034 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7035 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7036 try_y += (offgrid ? 8 : 16);
7037 if (!ok) break;
7038 }
7039 if (!ok) break;
7040 if((usehei%16)>0) //Uneven height
7041 {
7042 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7043 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7044 }
7045 }
7046 313037 break;
7047 }
7048 case 13:
7049 case l_down:
7050 {
7051 295401 dx = dx1-s;
7052 295401 dy = dy2+s;
7053 295401 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7054 //sv = ((isSideViewGravity())?7:0);
7055
2/2
✓ Branch 0 taken 287977 times.
✓ Branch 1 taken 295401 times.
583378 for ( ; tries_x > 0; --tries_x )
7056 {
7057 295401 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7058 295401 try_y = 0;
7059
2/2
✓ Branch 0 taken 287977 times.
✓ Branch 1 taken 295401 times.
583378 for ( ; tries_y > 0; --tries_y )
7060 {
7061
4/4
✓ Branch 0 taken 290465 times.
✓ Branch 1 taken 4936 times.
✓ Branch 2 taken 288231 times.
✓ Branch 3 taken 2234 times.
583632 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7062
2/2
✓ Branch 0 taken 171 times.
✓ Branch 1 taken 288060 times.
288231 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7063 295401 try_y += (offgrid ? 8 : 16);
7064
2/2
✓ Branch 0 taken 287977 times.
✓ Branch 1 taken 7424 times.
295401 if (!ok) break;
7065 287977 }
7066
2/2
✓ Branch 0 taken 287977 times.
✓ Branch 1 taken 7424 times.
295401 if (!ok) break;
7067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287977 times.
287977 if((usehei%16)>0) //Uneven height
7068 {
7069 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7070 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7071 }
7072 287977 try_x += (offgrid ? 8 : 16);
7073 287977 }
7074
2/2
✓ Branch 0 taken 287977 times.
✓ Branch 1 taken 7424 times.
295401 if(!ok) break;
7075
1/2
✓ Branch 0 taken 287977 times.
✗ Branch 1 not taken.
287977 if((usewid%16)>0) //Uneven width
7076 {
7077 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7078 try_y = 0;
7079 for ( ; tries_y > 0; --tries_y )
7080 {
7081 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7082 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7083 try_y += (offgrid ? 8 : 16);
7084 if (!ok) break;
7085 }
7086 if (!ok) break;
7087 if((usehei%16)>0) //Uneven height
7088 {
7089 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7090 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7091 }
7092 }
7093 287977 break;
7094 }
7095 case 15:
7096 case l_up:
7097 {
7098 280852 dx = dx1-s;
7099 280852 dy = dy1-s;
7100 280852 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7101 280852 sv = ((isSideViewGravity())?7:0);
7102
2/2
✓ Branch 0 taken 272641 times.
✓ Branch 1 taken 280852 times.
553493 for ( ; tries_x > 0; --tries_x )
7103 {
7104 280852 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7105 280852 try_y = 0;
7106
2/2
✓ Branch 0 taken 272641 times.
✓ Branch 1 taken 280852 times.
553493 for ( ; tries_y > 0; --tries_y )
7107 {
7108
4/4
✓ Branch 0 taken 276998 times.
✓ Branch 1 taken 3854 times.
✓ Branch 2 taken 274921 times.
✓ Branch 3 taken 2077 times.
555773 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7109
2/2
✓ Branch 0 taken 1714 times.
✓ Branch 1 taken 273207 times.
274921 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7110 280852 try_y += (offgrid ? 8 : 16);
7111
2/2
✓ Branch 0 taken 272641 times.
✓ Branch 1 taken 8211 times.
280852 if (!ok) break;
7112 272641 }
7113
2/2
✓ Branch 0 taken 272641 times.
✓ Branch 1 taken 8211 times.
280852 if (!ok) break;
7114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 272641 times.
272641 if((usehei%16)>0) //Uneven height
7115 {
7116 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7117 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7118 }
7119 272641 try_x += (offgrid ? 8 : 16);
7120 272641 }
7121
2/2
✓ Branch 0 taken 272641 times.
✓ Branch 1 taken 8211 times.
280852 if(!ok) break;
7122
1/2
✓ Branch 0 taken 272641 times.
✗ Branch 1 not taken.
272641 if((usewid%16)>0) //Uneven width
7123 {
7124 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7125 try_y = 0;
7126 for ( ; tries_y > 0; --tries_y )
7127 {
7128 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7129 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7130 try_y += (offgrid ? 8 : 16);
7131 if (!ok) break;
7132 }
7133 if (!ok) break;
7134 if((usehei%16)>0) //Uneven height
7135 {
7136 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7137 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7138 }
7139 }
7140 272641 break;
7141 }
7142 default:
7143 1093 db=99;
7144 1093 return true;
7145 }
7146 //Z_eventlog("\n");
7147 3492938 return ok;
7148 3495563 }
7149
7150
7151 2255301 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
7152 {
7153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2255301 times.
2255301 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2255301 times.
2255301 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7155
1/2
✓ Branch 0 taken 2255301 times.
✗ Branch 1 not taken.
2255301 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7156
1/2
✓ Branch 0 taken 2255301 times.
✗ Branch 1 not taken.
2255301 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7157 2255301 --usewid;
7158 2255301 --usehei;
7159 2255301 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
7160 }
7161
7162 618801 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
7163 {
7164 618801 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
7165
7166
4/4
✓ Branch 0 taken 4686 times.
✓ Branch 1 taken 614115 times.
✓ Branch 2 taken 3523 times.
✓ Branch 3 taken 1163 times.
618801 if(special==spw_clipright&&ndir==right)
7167 {
7168 1163 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
7169 1163 }
7170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618801 times.
618801 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 618801 times.
618801 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7172
1/2
✓ Branch 0 taken 618801 times.
✗ Branch 1 not taken.
618801 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7173
1/2
✓ Branch 0 taken 618801 times.
✗ Branch 1 not taken.
618801 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7174 618801 --usewid;
7175 618801 --usehei;
7176
2/2
✓ Branch 0 taken 331743 times.
✓ Branch 1 taken 287058 times.
618801 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
7177 }
7178
7179 61429 bool enemy::canmove(int32_t ndir, bool kb)
7180 {
7181 61429 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
7182 }
7183
7184 // 8-directional
7185 375 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7186 {
7187 375 int32_t ndir=0;
7188
7189 // can move straight, check if it wants to turn
7190
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 8 times.
375 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
7191 {
7192
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367 if(grumble && (zc_oldrand()&4)<grumble) //Homing
7193 {
7194 int32_t w = Lwpns.idFirst(wBait);
7195
7196 if(w>=0)
7197 {
7198 int32_t bx = Lwpns.spr(w)->x;
7199 int32_t by = Lwpns.spr(w)->y;
7200
7201 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7202
7203 if(abs(int32_t(y)-by)>14)
7204 {
7205 if(ndir>0) // Already left or right
7206 {
7207 // Making the diagonal directions
7208 ndir += (by<y) ? 2 : 4;
7209 }
7210 else
7211 {
7212 ndir = (by<y) ? up : down;
7213 }
7214 }
7215
7216 if(canmove(ndir,special,false))
7217 {
7218 dir=ndir;
7219 return;
7220 }
7221 }
7222 }
7223
7224 // Homing added.
7225
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 367 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
367 if(newhoming && (zc_oldrand()&255)<newhoming)
7226 {
7227 ndir = lined_up(8,true);
7228
7229 if(ndir>=0 && canmove(ndir,special,false))
7230 {
7231 dir=ndir;
7232 }
7233
7234 return;
7235 }
7236
7237 367 int32_t r=zc_oldrand();
7238
7239
2/4
✓ Branch 0 taken 367 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 367 times.
367 if(newrate>0 && !(r%newrate))
7240 {
7241 367 ndir = ((dir+((r&64)?-1:1))&7)+8;
7242 367 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7243
7244
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 14 times.
367 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7245 353 dir=ndir;
7246
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7247 11 dir=ndir2;
7248
7249
3/4
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 353 times.
✗ Branch 3 not taken.
367 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7250 // due to numerous lost fractional components. -L
7251 {
7252 x.doFloor();
7253 y.doFloor();
7254 }
7255 367 }
7256
7257 367 return;
7258 }
7259
7260 // can't move straight, must turn
7261 8 int32_t i=0;
7262
7263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 for(; i<32; i++) // Try random dir
7264 {
7265 15 ndir=(zc_oldrand()&7)+8;
7266
7267
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7268 8 break;
7269 7 }
7270
7271
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(i==32)
7272 {
7273 for(ndir=8; ndir<16; ndir++)
7274 {
7275 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7276 goto ok;
7277 }
7278
7279 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7280 }
7281
7282 ok:
7283 8 dir=ndir;
7284 8 x.doFloor();
7285 8 y.doFloor();
7286 375 }
7287
7288 283367 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7289 {
7290 283367 int32_t ndir=0;
7291
7292 // can move straight, check if it wants to turn
7293
2/2
✓ Branch 0 taken 266875 times.
✓ Branch 1 taken 16492 times.
283367 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
7294 {
7295
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 266668 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
266875 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
7296 {
7297 101 int32_t i = Lwpns.idFirst(wBait);
7298
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
7299 {
7300 weapon *w = (weapon*)Lwpns.spr(i);
7301 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7302 {
7303 int32_t currentrange;
7304 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7305 else currentrange = -1;
7306 int curid = i;
7307 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7308 for(; i<Lwpns.Count(); ++i)
7309 {
7310 weapon *lw = (weapon*)Lwpns.spr(i);
7311 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7312 {
7313 currentrange = distance(x, y, lw->x, lw->y);
7314 curid = i;
7315 }
7316 }
7317 i = curid;
7318 if (currentrange == -1) i = -1;
7319 }
7320 else
7321 {
7322 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7323 }
7324 if(i>=0)
7325 {
7326 int32_t bx = Lwpns.spr(i)->x;
7327 int32_t by = Lwpns.spr(i)->y;
7328
7329 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7330
7331 if(abs(int32_t(y)-by)>14)
7332 {
7333 if(ndir>0) // Already left or right
7334 {
7335 // Making the diagonal directions
7336 ndir += (by<y) ? 2 : 4;
7337 }
7338 else
7339 {
7340 ndir = (by<y) ? up : down;
7341 }
7342 }
7343 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7344 if(canmove(ndir,special,false))
7345 {
7346 dir=ndir;
7347 return;
7348 }
7349 }
7350 }
7351 101 }
7352
7353 // Homing added.
7354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 266875 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
266875 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
7355 {
7356 ndir = lined_up(8,true);
7357 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7358 if(ndir>=0 && canmove(ndir,special,false))
7359 {
7360 dir=ndir;
7361 }
7362
7363 return;
7364 }
7365
7366 266875 int32_t r=zc_oldrand();
7367
7368
4/4
✓ Branch 0 taken 171868 times.
✓ Branch 1 taken 95007 times.
✓ Branch 2 taken 92812 times.
✓ Branch 3 taken 79056 times.
266875 if(newrate>0 && !(r%newrate))
7369 {
7370 79056 ndir = ((dir+((r&64)?-1:1))&7)+8;
7371 79056 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7372
7373
2/2
✓ Branch 0 taken 76413 times.
✓ Branch 1 taken 2643 times.
79056 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7374 76413 dir=ndir;
7375
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 2538 times.
2643 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7376 2538 dir=ndir2;
7377
7378
4/4
✓ Branch 0 taken 76413 times.
✓ Branch 1 taken 2643 times.
✓ Branch 2 taken 72903 times.
✓ Branch 3 taken 3510 times.
79056 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7379 // due to numerous lost fractional components. -L
7380 {
7381 3510 x.doFloor();
7382 3510 y.doFloor();
7383 3510 }
7384 79056 }
7385
7386 266875 return;
7387 }
7388
7389 // can't move straight, must turn
7390 16492 int32_t i=0;
7391
7392
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 30575 times.
30589 for(; i<32; i++) // Try random dir
7393 {
7394 30575 ndir=(zc_oldrand()&7)+8;
7395
7396
2/2
✓ Branch 0 taken 14097 times.
✓ Branch 1 taken 16478 times.
30575 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7397 16478 break;
7398 14097 }
7399
7400
2/2
✓ Branch 0 taken 16478 times.
✓ Branch 1 taken 14 times.
16496 if(i==32)
7401 {
7402
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 4 times.
48 for(ndir=8; ndir<16; ndir++)
7403 {
7404
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 10 times.
44 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7405 10 goto ok;
7406 34 }
7407
7408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7409 4 }
7410
7411 ok:
7412 16492 dir=ndir;
7413 16492 x.doFloor();
7414 16492 y.doFloor();
7415 283367 }
7416
7417 279940 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
7418 {
7419 279940 newdir_8(newrate,newhoming,special,0,-8,15,15);
7420 279940 }
7421
7422 375 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
7423 {
7424 375 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
7425 375 }
7426
7427 // makes the enemy slide backwards when hit
7428 // sclk: first byte is clk, second byte is dir
7429 // makes the enemy slide backwards when hit
7430 // sclk: first byte is clk, second byte is dir
7431 8661678 int32_t enemy::slide()
7432 {
7433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8661678 times.
8661678 if(script_knockback_clk!=0) //scripted knockback
7434 {
7435 sclk = 0;
7436 return 1; //scripted knockback ran
7437 }
7438
5/6
✓ Branch 0 taken 53429 times.
✓ Branch 1 taken 8608249 times.
✓ Branch 2 taken 5357 times.
✓ Branch 3 taken 48072 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5357 times.
8661678 if(sclk==0 || (hp<=0 && !immortal))
7439 8613606 return 0;
7440
7441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48072 times.
48072 if(knockbackflags & FLAG_NOSLIDE)
7442 {
7443 sclk = 0;
7444 if(!OFFGRID_ENEMY)
7445 {
7446 //Fix to grid
7447 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
7448 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
7449 do_fix(x, 16, true);
7450 do_fix(y, 16, true);
7451 }
7452 return 0;
7453 }
7454
8/10
✓ Branch 0 taken 4852 times.
✓ Branch 1 taken 43220 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 4827 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3620 times.
✓ Branch 7 taken 1207 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
48072 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
7455 {
7456 1207 sclk=0;
7457 1207 return 0;
7458 }
7459
7460 46865 --sclk;
7461
7462
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5694 times.
✓ Branch 2 taken 5991 times.
✓ Branch 3 taken 15560 times.
✓ Branch 4 taken 17963 times.
46865 switch(sclk>>8)
7463 {
7464 case up:
7465 {
7466
4/4
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 5061 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 5688 times.
5694 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
7467 {
7468 6 sclk=0;
7469 6 return 0;
7470 }
7471
4/4
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 5055 times.
✓ Branch 2 taken 529 times.
✓ Branch 3 taken 104 times.
5688 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7472
7473 5584 break;
7474 }
7475 case down:
7476 {
7477
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5989 times.
5991 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
7478 {
7479 2 sclk=0;
7480 2 return 0;
7481 }
7482
4/4
✓ Branch 0 taken 734 times.
✓ Branch 1 taken 5255 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 95 times.
5989 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7483
7484 5894 break;
7485 }
7486 case left:
7487 {
7488
4/4
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 14249 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 15547 times.
15560 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
7489 {
7490 13 sclk=0;
7491 13 return 0;
7492 }
7493
4/4
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 14236 times.
✓ Branch 2 taken 1204 times.
✓ Branch 3 taken 107 times.
15547 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
7494
7495 15440 break;
7496 }
7497 case right:
7498 {
7499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17963 times.
17963 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
7500 {
7501 sclk=0;
7502 return 0;
7503 }
7504
4/4
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 15677 times.
✓ Branch 2 taken 2130 times.
✓ Branch 3 taken 156 times.
17963 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7505 17807 break;
7506 }
7507 }
7508
7509 46382 int32_t move = knockbackSpeed;
7510
2/2
✓ Branch 0 taken 43983 times.
✓ Branch 1 taken 46382 times.
90365 while(move>0)
7511 {
7512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46382 times.
46382 int32_t thismove = zc_min(8, move);
7513 46382 move -= thismove;
7514 46382 hitdir = (sclk>>8);
7515
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5584 times.
✓ Branch 2 taken 5894 times.
✓ Branch 3 taken 15440 times.
✓ Branch 4 taken 17807 times.
46382 switch(sclk>>8)
7516 {
7517 case up:
7518 5584 y-=thismove;
7519 5584 break;
7520
7521 case down:
7522 5894 y+=thismove;
7523 5894 break;
7524
7525 case left:
7526 15440 x-=thismove;
7527 15440 break;
7528
7529 case right:
7530 17807 x+=thismove;
7531 17807 break;
7532 }
7533
2/2
✓ Branch 0 taken 43983 times.
✓ Branch 1 taken 2399 times.
46382 if(!canmove(sclk>>8,(zfix)0,0,true))
7534 {
7535
3/3
✓ Branch 0 taken 996 times.
✓ Branch 1 taken 1399 times.
✓ Branch 2 taken 4 times.
2399 switch(sclk>>8)
7536 {
7537 case up:
7538 case down:
7539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 996 times.
996 if(y < 0)
7540 y = 0;
7541
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 823 times.
996 else if((int32_t(y)&15) > 7)
7542 173 y=(int32_t(y)&0xF0)+16;
7543 else
7544 823 y=(int32_t(y)&0xF0);
7545
7546 996 break;
7547
7548 case left:
7549 case right:
7550
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1398 times.
1399 if(x < 0)
7551 1 x = 0;
7552
2/2
✓ Branch 0 taken 415 times.
✓ Branch 1 taken 983 times.
1398 else if((int32_t(x)&15) > 7)
7553 415 x=(int32_t(x)&0xF0)+16;
7554 else
7555 983 x=(int32_t(x)&0xF0);
7556
7557 1399 break;
7558 }
7559
7560 2399 sclk=0;
7561 2399 clk3=0;
7562 2399 break;
7563 }
7564 }
7565
7566
2/2
✓ Branch 0 taken 42761 times.
✓ Branch 1 taken 3621 times.
46382 if((sclk&255)==0)
7567 {
7568 //hitdir = -1;
7569 3621 sclk=0;
7570 3621 }
7571 46382 return 2;
7572 8661678 }
7573
7574 bool enemy::can_slide()
7575 {
7576 if(sclk==0 || (hp<=0 && !immortal))
7577 return false;
7578
7579 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
7580 {
7581 return false;
7582 }
7583
7584 return true;
7585 }
7586
7587 bool enemy::fslide()
7588 {
7589 if(sclk==0 || (hp<=0 && !immortal))
7590 return false;
7591
7592 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
7593 {
7594 sclk=0;
7595 return false;
7596 }
7597
7598 --sclk;
7599
7600 switch(sclk>>8)
7601 {
7602 case up:
7603 if(y<=16)
7604 {
7605 sclk=0;
7606 return false;
7607 }
7608
7609 break;
7610
7611 case down:
7612 if(y>=160)
7613 {
7614 sclk=0;
7615 return false;
7616 }
7617
7618 break;
7619
7620 case left:
7621 if(x<=16)
7622 {
7623 sclk=0;
7624 return false;
7625 }
7626
7627 break;
7628
7629 case right:
7630 if(x>=240)
7631 {
7632 sclk=0;
7633 return false;
7634 }
7635
7636 break;
7637 }
7638 hitdir = (sclk>>8);
7639 switch(sclk>>8)
7640 {
7641 case up:
7642 y-=4;
7643 break;
7644
7645 case down:
7646 y+=4;
7647 break;
7648
7649 case left:
7650 x-=4;
7651 break;
7652
7653 case right:
7654 x+=4;
7655 break;
7656 }
7657
7658 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
7659 {
7660 switch(sclk>>8)
7661 {
7662 case up:
7663 case down:
7664 if((int32_t(y)&15) > 7)
7665 y=(int32_t(y)&0xF0)+16;
7666 else
7667 y=(int32_t(y)&0xF0);
7668
7669 break;
7670
7671 case left:
7672 case right:
7673 if((int32_t(x)&15) > 7)
7674 x=(int32_t(x)&0xF0)+16;
7675 else
7676 x=(int32_t(x)&0xF0);
7677
7678 break;
7679 }
7680
7681 sclk=0;
7682 clk3=0;
7683 }
7684
7685 if((sclk&255)==0)
7686 sclk=0;
7687
7688 return true;
7689 }
7690
7691 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
7692 {
7693 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
7694 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
7695 bool ret = sprite::knockback(time, dir, speed);
7696 if(ret) sclk = 0; //kill engine knockback if interrupted
7697 //! Perhaps also set hitdir here, if needed for timing? -Z
7698 return ret;
7699 }
7700
7701 19303889 bool enemy::runKnockback()
7702 {
7703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19303889 times.
19303889 if((script_knockback_clk&0xFF)==0)
7704 {
7705 19303889 script_knockback_clk = 0;
7706 19303889 return false;
7707 }
7708 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
7709 {
7710 return false;
7711 }
7712 int32_t move = script_knockback_speed;
7713 int32_t kb_dir = script_knockback_clk>>8;
7714 --script_knockback_clk;
7715
7716 while(move>0)
7717 {
7718 int32_t thismove = zc_min(get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
7719 move -= thismove;
7720 hitdir = kb_dir;
7721 switch(kb_dir)
7722 {
7723 case r_up:
7724 case l_up:
7725 case up:
7726 y-=thismove;
7727 break;
7728
7729 case r_down:
7730 case l_down:
7731 case down:
7732 y+=thismove;
7733 break;
7734 }
7735 switch(kb_dir)
7736 {
7737 case l_up:
7738 case l_down:
7739 case left:
7740 x-=thismove;
7741 break;
7742
7743 case r_up:
7744 case r_down:
7745 case right:
7746 x+=thismove;
7747 break;
7748 }
7749 if (get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK))
7750 {
7751 if(!canmove(kb_dir,(zfix)0,0,true))
7752 {
7753 script_knockback_clk=0;
7754 clk3=0;
7755 //Fix to grid
7756 switch(kb_dir)
7757 {
7758 case up:
7759 case down:
7760 break;
7761 default:
7762 if(x < 0)
7763 x = 0;
7764 else if((int32_t(x)&15) > 7)
7765 x=(int32_t(x)&0xF0)+16;
7766 else
7767 x=(int32_t(x)&0xF0);
7768 break;
7769 }
7770 switch(kb_dir)
7771 {
7772 case left:
7773 case right:
7774 break;
7775 default:
7776 if(y < 0)
7777 y = 0;
7778 else if((int32_t(y)&15) > 7)
7779 y=(int32_t(y)&0xF0)+16;
7780 else
7781 y=(int32_t(y)&0xF0);
7782 break;
7783 }
7784 break;
7785 }
7786 }
7787 else
7788 {
7789 if(!scr_canplace(x,y,0,true))
7790 {
7791 script_knockback_clk=0;
7792 clk3=0;
7793 //Fix to grid
7794 if (OFFGRID_ENEMY)
7795 {
7796 switch(kb_dir)
7797 {
7798 case up:
7799 case down:
7800 break;
7801 default:
7802 if(x < 0)
7803 x = 0;
7804 else if((int32_t(x)&7) > 3)
7805 x=(int32_t(x)&0xF8)+8;
7806 else
7807 x=(int32_t(x)&0xF8);
7808 break;
7809 }
7810 switch(kb_dir)
7811 {
7812 case left:
7813 case right:
7814 break;
7815 default:
7816 if(y < 0)
7817 y = 0;
7818 else if((int32_t(y)&7) > 3)
7819 y=(int32_t(y)&0xF8)+8;
7820 else
7821 y=(int32_t(y)&0xF8);
7822 break;
7823 }
7824 }
7825 else
7826 {
7827 switch(kb_dir)
7828 {
7829 case up:
7830 case down:
7831 break;
7832 default:
7833 if(x < 0)
7834 x = 0;
7835 else if((int32_t(x)&15) > 7)
7836 x=(int32_t(x)&0xF0)+16;
7837 else
7838 x=(int32_t(x)&0xF0);
7839 break;
7840 }
7841 switch(kb_dir)
7842 {
7843 case left:
7844 case right:
7845 break;
7846 default:
7847 if(y < 0)
7848 y = 0;
7849 else if((int32_t(y)&15) > 7)
7850 y=(int32_t(y)&0xF0)+16;
7851 else
7852 y=(int32_t(y)&0xF0);
7853 break;
7854 }
7855 }
7856 break;
7857 }
7858
7859 }
7860 }
7861 return true;
7862 19303889 }
7863 // changes enemy's direction, checking restrictions
7864 // rate: 0 = no random changes, 16 = always random change
7865 // homing: 0 = none, 256 = always
7866 // grumble 0 = none, 4 = strongest appetite
7867 286994 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
7868 {
7869 286994 int32_t ndir=-1;
7870
7871
4/4
✓ Branch 0 taken 65452 times.
✓ Branch 1 taken 221542 times.
✓ Branch 2 taken 23332 times.
✓ Branch 3 taken 42120 times.
286994 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
7872 {
7873 42120 int32_t i = Lwpns.idFirst(wBait);
7874
1/2
✓ Branch 0 taken 42120 times.
✗ Branch 1 not taken.
42120 if(i >= 0) //idfirst returns -1 if it can't find any
7875 {
7876 weapon *w = (weapon*)Lwpns.spr(i);
7877 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7878 {
7879 int32_t currentrange;
7880 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7881 else currentrange = -1;
7882 int curid = i;
7883 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7884 for(; i<Lwpns.Count(); ++i)
7885 {
7886 weapon *lw = (weapon*)Lwpns.spr(i);
7887 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7888 {
7889 currentrange = distance(x, y, lw->x, lw->y);
7890 curid = i;
7891 }
7892 }
7893 i = curid;
7894 if (currentrange == -1) i = -1;
7895 }
7896 else
7897 {
7898 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7899 }
7900 if (i >= 0)
7901 {
7902 int32_t bx = Lwpns.spr(i)->x;
7903 int32_t by = Lwpns.spr(i)->y;
7904
7905 if(abs(int32_t(y)-by)>14)
7906 {
7907 ndir = (by<y) ? up : down;
7908 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7909 if(canmove(ndir,special,false))
7910 {
7911 dir=ndir;
7912 return;
7913 }
7914 }
7915
7916 ndir = (bx<x) ? left : right;
7917 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7918 if(canmove(ndir,special,false))
7919 {
7920 dir=ndir;
7921 return;
7922 }
7923 }
7924 }
7925 42120 }
7926
7927
2/2
✓ Branch 0 taken 196737 times.
✓ Branch 1 taken 90257 times.
286994 if((zc_oldrand()&255)<abs(newhoming))
7928 {
7929 90257 ndir = lined_up(8,false);
7930
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 90257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
90257 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7931
4/4
✓ Branch 0 taken 24021 times.
✓ Branch 1 taken 66236 times.
✓ Branch 2 taken 3222 times.
✓ Branch 3 taken 20799 times.
90257 if(ndir>=0 && canmove(ndir,special,false))
7932 {
7933 20799 dir=ndir;
7934 20799 return;
7935 }
7936 69458 }
7937
7938 266195 int32_t i=0;
7939
7940
2/2
✓ Branch 0 taken 1156 times.
✓ Branch 1 taken 591462 times.
592618 for(; i<32; i++)
7941 {
7942 591462 int32_t r=zc_oldrand();
7943
7944
2/2
✓ Branch 0 taken 182374 times.
✓ Branch 1 taken 409088 times.
591462 if((r&15)<newrate)
7945 182374 ndir=(r>>4)&3;
7946 else
7947 409088 ndir=dir;
7948
7949
2/2
✓ Branch 0 taken 326423 times.
✓ Branch 1 taken 265039 times.
591462 if(canmove(ndir,special,false))
7950 265039 break;
7951 326423 }
7952
7953
2/2
✓ Branch 0 taken 265039 times.
✓ Branch 1 taken 1156 times.
266602 if(i==32)
7954 {
7955
2/2
✓ Branch 0 taken 3318 times.
✓ Branch 1 taken 407 times.
3725 for(ndir=0; ndir<4; ndir++)
7956 {
7957
2/2
✓ Branch 0 taken 2569 times.
✓ Branch 1 taken 749 times.
3318 if(canmove(ndir,special,false))
7958 749 goto ok;
7959 2569 }
7960
7961
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 347 times.
407 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7962 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
7963 407 }
7964
7965 ok:
7966 266195 dir = ndir;
7967 286994 }
7968
7969 940 void enemy::newdir()
7970 {
7971 940 newdir(4,0,spw_none);
7972 940 }
7973
7974 zfix enemy::distance_left()
7975 {
7976 int32_t a2=x.getInt();
7977 int32_t b2=y.getInt();
7978
7979 switch(dir)
7980 {
7981 case up:
7982 return (zfix)(b2&0xF);
7983
7984 case down:
7985 return (zfix)(16-(b2&0xF));
7986
7987 case left:
7988 return (zfix)(a2&0xF);
7989
7990 case right:
7991 return (zfix)(16-(a2&0xF));
7992 }
7993
7994 return (zfix)0;
7995 }
7996
7997 // keeps walking around
7998 223798 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
7999 {
8000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 223798 times.
223798 if(slide())
8001 return;
8002
8003
8/12
✓ Branch 0 taken 221555 times.
✓ Branch 1 taken 2243 times.
✓ Branch 2 taken 221555 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 219690 times.
✓ Branch 5 taken 1865 times.
✓ Branch 6 taken 219690 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 219690 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 219690 times.
223798 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
8004 4108 return;
8005
8006
2/2
✓ Branch 0 taken 15245 times.
✓ Branch 1 taken 204445 times.
219690 if(clk3<=0)
8007 {
8008 15245 fix_coords(true);
8009 15245 newdir(newrate,newhoming,special);
8010
8011
1/2
✓ Branch 0 taken 15245 times.
✗ Branch 1 not taken.
15245 if(step==0)
8012 clk3=0;
8013 else
8014 15245 clk3=int32_t(16.0/step);
8015 15245 }
8016
2/2
✓ Branch 0 taken 204424 times.
✓ Branch 1 taken 21 times.
204445 else if(scored)
8017 {
8018 21 dir^=1;
8019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8020 else clk3=32767;
8021 21 }
8022
8023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 219690 times.
219690 if (step != 0) --clk3;
8024 219690 move(step);
8025 223798 }
8026
8027 void enemy::constant_walk()
8028 {
8029 constant_walk(4,0,spw_none);
8030 }
8031
8032 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
8033 {
8034 18230 return (newy<<8)+newx;
8035 }
8036
8037 // for variable step rates
8038 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
8039 {
8040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
8041 return;
8042
8043
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
8044 34220 return;
8045
8046 200047 zfix dx = (zfix)0;
8047 200047 zfix dy = (zfix)0;
8048
8049
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
8050 {
8051 case 8:
8052 case up:
8053 43624 dy-=step;
8054 43624 break;
8055
8056 case 12:
8057 case down:
8058 44366 dy+=step;
8059 44366 break;
8060
8061 case 14:
8062 case left:
8063 53763 dx-=step;
8064 53763 break;
8065
8066 case 10:
8067 case right:
8068 56539 dx+=step;
8069 56539 break;
8070
8071 case 15:
8072 case l_up:
8073 dx-=step;
8074 dy-=step;
8075 break;
8076
8077 case 9:
8078 case r_up:
8079 dx+=step;
8080 dy-=step;
8081 break;
8082
8083 case 13:
8084 case l_down:
8085 dx-=step;
8086 dy+=step;
8087 break;
8088
8089 case 11:
8090 case r_down:
8091 dx+=step;
8092 dy+=step;
8093 break;
8094 }
8095
8096
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
8097 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
8098 {
8099 6228 fix_coords();
8100 6228 newdir(newrate,newhoming,special);
8101 6228 clk3=pos(x,y);
8102 6228 }
8103
8104 200047 move(step);
8105 234267 }
8106
8107 // pauses for a while after it makes a complete move (to a new square)
8108 6920724 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
8109 {
8110
4/4
✓ Branch 0 taken 39782 times.
✓ Branch 1 taken 6880942 times.
✓ Branch 2 taken 32151 times.
✓ Branch 3 taken 7631 times.
6920724 if(sclk && clk2)
8111 {
8112 7631 clk3=0;
8113 7631 }
8114
8115
11/14
✓ Branch 0 taken 6885788 times.
✓ Branch 1 taken 34936 times.
✓ Branch 2 taken 6885788 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6885788 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6623943 times.
✓ Branch 7 taken 261845 times.
✓ Branch 8 taken 6500231 times.
✓ Branch 9 taken 123712 times.
✓ Branch 10 taken 6498459 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6498459 times.
6920724 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8116 {
8117 422265 return;
8118 }
8119
8120
2/2
✓ Branch 0 taken 1304856 times.
✓ Branch 1 taken 5193603 times.
6498459 if(clk2>0)
8121 {
8122 1304856 --clk2;
8123 1304856 return;
8124 }
8125
8126
2/2
✓ Branch 0 taken 227998 times.
✓ Branch 1 taken 4965605 times.
5193603 if(clk3<=0)
8127 {
8128 227998 fix_coords(true);
8129 227998 newdir(newrate,newhoming,special);
8130 227998 clk3=int32_t(16.0/step);
8131
2/2
✓ Branch 0 taken 227989 times.
✓ Branch 1 taken 9 times.
227998 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
8132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227998 times.
227998 if(clk2<0)
8133 {
8134 clk2=0;
8135 }
8136
2/2
✓ Branch 0 taken 32198 times.
✓ Branch 1 taken 195800 times.
227998 else if((zc_oldrand()&15)<newhrate)
8137 {
8138 32198 clk2=haltcnt;
8139 32198 return;
8140 }
8141 195800 }
8142
2/2
✓ Branch 0 taken 4964255 times.
✓ Branch 1 taken 1350 times.
4965605 else if(scored)
8143 {
8144 1350 dir^=1;
8145
8146
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1349 times.
1350 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8147 1 else clk3=32767;
8148 1350 }
8149
8150
2/2
✓ Branch 0 taken 12025 times.
✓ Branch 1 taken 5149380 times.
5161405 if (step != 0) --clk3;
8151 5161405 move(step);
8152 6920724 }
8153
8154 // 8-directional movement, aligns to 8 pixels
8155 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
8156 {
8157 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8158 return;
8159
8160 if(clk3<=0)
8161 {
8162 newdir_8(newrate,newhoming,special);
8163 clk3=int32_t(8.0/step);
8164 if (step == 0) clk3 = 32767;
8165 }
8166
8167 if (step != 0) --clk3;
8168 move(step);
8169 }
8170 // 8-directional movement, aligns to 8 pixels
8171 78326 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
8172 {
8173
6/12
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78326 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 78326 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 78326 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 78326 times.
78326 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8174 return;
8175
8176
2/2
✓ Branch 0 taken 72597 times.
✓ Branch 1 taken 5729 times.
78326 if(clk3<=0)
8177 {
8178 5729 newdir_8(newrate,newhoming,special);
8179 5729 clk3=int32_t(8.0/step);
8180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5729 times.
5729 if (step == 0) clk3 = 32767;
8181 5729 }
8182
8183
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if (step != 0) --clk3;
8184 78326 move(step);
8185 78326 }
8186
8187 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
8188 {
8189 if(clk<0 || dying || stunclk || watch || frozenclock)
8190 return;
8191
8192 if(!canmove(dir,step,special,false))
8193 clk3=0;
8194
8195 if(clk2>0)
8196 {
8197 --clk2;
8198 return;
8199 }
8200
8201 if(clk3<=0)
8202 {
8203 newdir_8(newrate,newhoming,special);
8204 clk3=newclk;
8205
8206 if(clk2<0)
8207 {
8208 clk2=0;
8209 }
8210 else if((zc_oldrand()&15)<newhrate)
8211 {
8212 newdir_8(newrate,newhoming,special);
8213 clk2=haltcnt;
8214 return;
8215 }
8216 }
8217
8218 --clk3;
8219 move(step);
8220 }
8221
8222 // 8-directional movement, no alignment
8223 2289696 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
8224 {
8225
9/12
✓ Branch 0 taken 2195791 times.
✓ Branch 1 taken 93905 times.
✓ Branch 2 taken 2195791 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2174298 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2164627 times.
✓ Branch 7 taken 9671 times.
✓ Branch 8 taken 2164627 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2164627 times.
2289696 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8226 125069 return;
8227
8228
2/2
✓ Branch 0 taken 2149056 times.
✓ Branch 1 taken 15571 times.
2164627 if(!canmove(dir,step,special,false))
8229 15571 clk3=0;
8230
8231
2/2
✓ Branch 0 taken 1890416 times.
✓ Branch 1 taken 274211 times.
2164627 if(clk3<=0)
8232 {
8233 274211 newdir_8(newrate,newhoming,special);
8234 274211 clk3=newclk;
8235 274211 }
8236
8237 2164627 --clk3;
8238 2164627 move(step);
8239 2289696 }
8240
8241 // same as above but with variable enemy size
8242 51782 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
8243 {
8244
8/12
✓ Branch 0 taken 51015 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51015 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51015 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 50964 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 50964 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 50964 times.
51782 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8245 818 return;
8246
8247
2/2
✓ Branch 0 taken 50457 times.
✓ Branch 1 taken 507 times.
50964 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
8248 507 clk3=0;
8249
8250
2/2
✓ Branch 0 taken 47537 times.
✓ Branch 1 taken 3427 times.
50964 if(clk3<=0)
8251 {
8252 3427 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
8253 3427 clk3=newclk;
8254 3427 }
8255
8256 50964 --clk3;
8257 50964 move(step);
8258 51782 }
8259
8260 // the variable speed floater movement
8261 // ms is max speed
8262 // ss is step speed
8263 // s is step count
8264 // p is pause count
8265 // g is graduality :)
8266 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
8267 1894781 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8268 {
8269 1894781 ++clk2;
8270 1894781 byte over_pit = overpit(this);
8271
8272
4/4
✓ Branch 0 taken 410894 times.
✓ Branch 1 taken 1483887 times.
✓ Branch 2 taken 410627 times.
✓ Branch 3 taken 267 times.
1894781 if(dmisc1 && over_pit) p = 0;
8273
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 34860 times.
✓ Branch 2 taken 733207 times.
✓ Branch 3 taken 1047617 times.
✓ Branch 4 taken 79097 times.
1894781 switch(movestatus)
8274 {
8275 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
8276 //! if the conditions prevent it, we jump back to case 2.
8277 case 0: // paused
8278
2/2
✓ Branch 0 taken 34205 times.
✓ Branch 1 taken 655 times.
34860 if(clk2>=p)
8279 {
8280 655 movestatus=1;
8281 655 clk2=0;
8282 655 }
8283
8284 34860 break;
8285
8286 case 1: // speeding up
8287
1/2
✓ Branch 0 taken 733207 times.
✗ Branch 1 not taken.
733207 if (s >= 0)
8288 {
8289
2/2
✓ Branch 0 taken 728260 times.
✓ Branch 1 taken 4947 times.
733207 if(clk2<g*s)
8290 {
8291
2/2
✓ Branch 0 taken 681672 times.
✓ Branch 1 taken 46588 times.
728260 if(!((clk2-1)%g))
8292 46588 step+=ss;
8293 728260 }
8294 else
8295 {
8296 4947 movestatus=2;
8297 4947 clk2=0;
8298 }
8299 733207 }
8300 else
8301 {
8302 if(step < ms)
8303 {
8304 if(!((clk2-1)%g))
8305 {
8306 step+=ss;
8307 if (step >= ms) step = ms;
8308 }
8309 }
8310 else
8311 {
8312 step = ms;
8313 movestatus=2;
8314 clk2=0;
8315 }
8316 }
8317
8318 733207 break;
8319
8320 case 2: // normal
8321 1047617 step=ms;
8322
8323
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1047617 times.
✓ Branch 2 taken 213965 times.
✓ Branch 3 taken 833652 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 833652 times.
✓ Branch 6 taken 832554 times.
✓ Branch 7 taken 1098 times.
1047617 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
8324 {
8325
1/2
✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
1098 if (s >= 0) step=ss*s;
8326 else step=ms;
8327 1098 movestatus=3;
8328 1098 clk2=0;
8329 1098 }
8330
8331 1047617 break;
8332
8333 case 3: // slowing down
8334
1/2
✓ Branch 0 taken 79097 times.
✗ Branch 1 not taken.
79097 if (s >= 0)
8335 {
8336
2/2
✓ Branch 0 taken 78318 times.
✓ Branch 1 taken 779 times.
79097 if(clk2<=g*s)
8337 {
8338 { //don't slow down over pits
8339
8340
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 78306 times.
78318 if(over_pit)
8341 {
8342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
8343 {
8344 step=ms;
8345 }
8346 12 }
8347 else //can slow down
8348 {
8349
4/4
✓ Branch 0 taken 4858 times.
✓ Branch 1 taken 73448 times.
✓ Branch 2 taken 4586 times.
✓ Branch 3 taken 272 times.
78306 if(!(clk2%g) && !dmisc1)
8350 4586 step-=ss;
8351 }
8352 }
8353
8354
8355 78318 }
8356 else
8357 {
8358 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8359 //this doesn't help keese, as they have a z of 0.
8360 //they always nee to run this check.
8361 {
8362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
779 if(over_pit &&!dmisc1)
8363 {
8364 --clk2; //if over a pit, don't land, and revert clock change
8365 }
8366 else //can land safely
8367 {
8368 779 movestatus=0;
8369
3/4
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 333 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
779 if(dmisc1&&!over_pit)
8370 446 step=0;
8371 779 clk2=0;
8372 }
8373 }
8374
8375 }
8376 79097 }
8377 else
8378 {
8379 if(step > 0)
8380 {
8381 if(over_pit)
8382 {
8383 if(dmisc1)
8384 {
8385 step=ms;
8386 }
8387 }
8388 else //can slow down
8389 {
8390 if(!(clk2%g))
8391 step-=ss;
8392 }
8393 }
8394 else
8395 {
8396 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8397 //this doesn't help keese, as they have a z of 0.
8398 //they always nee to run this check.
8399 if(over_pit)
8400 {
8401 step+=ss; //if over a pit, don't land, and revert clock change
8402 }
8403 else //can land safely
8404 {
8405 movestatus=0;
8406 step=0;
8407 clk2=0;
8408 }
8409 }
8410 }
8411
8412 79097 break;
8413 }
8414
8415
2/2
✓ Branch 0 taken 1051466 times.
✓ Branch 1 taken 843315 times.
1894781 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
8416 1894781 }
8417
8418 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
8419 {
8420 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
8421 }
8422
8423 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
8424 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
8425 474294 int32_t enemy::lined_up(int32_t range, bool dir8)
8426 {
8427 474294 int32_t lx = Hero.getX();
8428 474294 int32_t ly = Hero.getY();
8429
8430
2/2
✓ Branch 0 taken 18176 times.
✓ Branch 1 taken 456118 times.
474294 if(abs(lx-int32_t(x))<=range)
8431 {
8432
2/2
✓ Branch 0 taken 7122 times.
✓ Branch 1 taken 11054 times.
18176 if(ly<y)
8433 {
8434 7122 return up;
8435 }
8436
8437 11054 return down;
8438 }
8439
8440
2/2
✓ Branch 0 taken 21305 times.
✓ Branch 1 taken 434813 times.
456118 if(abs(ly-int32_t(y))<=range)
8441 {
8442
2/2
✓ Branch 0 taken 10711 times.
✓ Branch 1 taken 10594 times.
21305 if(lx<x)
8443 {
8444 10711 return left;
8445 }
8446
8447 10594 return right;
8448 }
8449
8450
2/2
✓ Branch 0 taken 87017 times.
✓ Branch 1 taken 347796 times.
434813 if(dir8)
8451 {
8452
2/2
✓ Branch 0 taken 119146 times.
✓ Branch 1 taken 228650 times.
347796 if(abs(lx-x)-abs(ly-y)<=range)
8453 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
8454 {
8455
2/2
✓ Branch 0 taken 52201 times.
✓ Branch 1 taken 66945 times.
119146 if(ly<y)
8456 {
8457
2/2
✓ Branch 0 taken 30148 times.
✓ Branch 1 taken 22053 times.
52201 if(lx<x)
8458 {
8459 30148 return l_up;
8460 }
8461 else
8462 {
8463 22053 return r_up;
8464 }
8465 }
8466 else
8467 {
8468
2/2
✓ Branch 0 taken 32948 times.
✓ Branch 1 taken 33997 times.
66945 if(lx<x)
8469 {
8470 33997 return l_down;
8471 }
8472 else
8473 {
8474 32948 return r_down;
8475 }
8476 }
8477 }
8478 228650 }
8479
8480 315667 return -1;
8481 474294 }
8482
8483 // returns true if Hero is within 'range' pixels of the enemy
8484 13649 bool enemy::HeroInRange(int32_t range)
8485 {
8486 13649 int32_t lx = Hero.getX();
8487 13649 int32_t ly = Hero.getY();
8488
2/2
✓ Branch 0 taken 11420 times.
✓ Branch 1 taken 2229 times.
13649 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
8489 }
8490
8491 // place the enemy in line with Hero (red wizzrobes)
8492 2280 void enemy::place_on_axis(bool floater, bool solid_ok)
8493 {
8494
6/6
✓ Branch 0 taken 1881 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 199 times.
✓ Branch 4 taken 1682 times.
✓ Branch 5 taken 399 times.
2280 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
8495
6/6
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 375 times.
✓ Branch 2 taken 1944 times.
✓ Branch 3 taken 336 times.
✓ Branch 4 taken 1569 times.
✓ Branch 5 taken 375 times.
2280 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
8496 2280 int32_t pos2=zc_oldrand()%23;
8497 2280 int32_t tried=0;
8498 2280 bool last_resort,placed=false;
8499
8500
8501 2280 do
8502 {
8503
2/2
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 1681 times.
4065 if(pos2<14)
8504 {
8505 2384 x=(pos2<<4)+16;
8506 2384 y=ly;
8507 2384 }
8508 else
8509 {
8510 1681 x=lx;
8511 1681 y=((pos2-14)<<4)+16;
8512 }
8513
8514 // Don't commit to a last resort if position is out of bounds.
8515
6/6
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 3745 times.
✓ Branch 3 taken 158 times.
✓ Branch 4 taken 126 times.
✓ Branch 5 taken 3619 times.
4065 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
8516
8517
4/4
✓ Branch 0 taken 2113 times.
✓ Branch 1 taken 1952 times.
✓ Branch 2 taken 3716 times.
✓ Branch 3 taken 2095 times.
4065 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
8518 {
8519 // Red Wizzrobes should be able to appear on water, but not other
8520 // solid combos; however, they could appear on solid combos in 2.10,
8521 // and some quests depend on that.
8522
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3528 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2280 times.
5668 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
8523 5668 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
8524 2280 placed=true;
8525 5668 }
8526
8527
3/6
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 3482 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1785 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5267 if(!placed && tried>=22 && last_resort)
8528 {
8529 placed=true;
8530 }
8531
8532 5267 ++tried;
8533 5267 pos2=(pos2+3)%23;
8534
2/2
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 3482 times.
5267 }
8535 5267 while(!placed);
8536
8537
2/2
✓ Branch 0 taken 2651 times.
✓ Branch 1 taken 831 times.
3482 if(y==ly)
8538 2651 dir=(x<lx)?right:left;
8539 else
8540 831 dir=(y<ly)?down:up;
8541
8542 3482 clk2=tried;
8543 3482 }
8544
8545 9171439 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
8546 {
8547 9171439 int32_t t = o_tile;
8548 9171439 int32_t b = o_tile;
8549
8550 // Darknuts, but also Wizzrobes and Wallmasters
8551
3/4
✓ Branch 0 taken 3375265 times.
✓ Branch 1 taken 5453811 times.
✓ Branch 2 taken 342363 times.
✗ Branch 3 not taken.
9171439 switch(family)
8552 {
8553 case eeWALK:
8554
5/6
✓ Branch 0 taken 369324 times.
✓ Branch 1 taken 5084487 times.
✓ Branch 2 taken 261311 times.
✓ Branch 3 taken 108013 times.
✓ Branch 4 taken 261311 times.
✗ Branch 5 not taken.
5453811 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
8555 {
8556 261311 tile=s_tile;
8557 261311 t=s_tile;
8558 261311 b=s_tile;
8559 261311 }
8560
8561 5453811 break;
8562
8563 case eeTRAP:
8564
4/6
✓ Branch 0 taken 121158 times.
✓ Branch 1 taken 221205 times.
✓ Branch 2 taken 121158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 121158 times.
342363 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
8565 {
8566 121158 tile=s_tile;
8567 121158 t=s_tile;
8568 121158 b=s_tile;
8569 121158 }
8570
8571 342363 break;
8572
8573 case eeSPINTILE:
8574 if(misc>=96 && do_animation)
8575 {
8576 tile=o_tile+frames*ndir;
8577 t=tile;
8578 }
8579
8580 break;
8581 }
8582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9171439 times.
9171439 if ( do_animation )
8583 {
8584
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 9008397 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133804 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8874593 times.
9171439 if(ndir!=0) switch(frames)
8585 {
8586 case 2:
8587 133804 tiledir_small(dir,ndir==4);
8588 133804 break;
8589
8590 case 3:
8591 tiledir_three(dir);
8592 break;
8593
8594 case 4:
8595 8874593 tiledir(dir,ndir==4);
8596 8874593 break;
8597 9008397 }
8598
8599
2/2
✓ Branch 0 taken 5453811 times.
✓ Branch 1 taken 3717628 times.
9171439 if(family==eeWALK)
8600
6/6
✓ Branch 0 taken 4340892 times.
✓ Branch 1 taken 1112919 times.
✓ Branch 2 taken 4094853 times.
✓ Branch 3 taken 1358958 times.
✓ Branch 4 taken 1072833 times.
✓ Branch 5 taken 286125 times.
5453811 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
8601 else
8602 3717628 tile+=f4;
8603 9171439 }
8604 9171439 return b;
8605 }
8606
8607 void enemy::tiledir_three(int32_t ndir)
8608 {
8609 if ( !do_animation ) return;
8610 flip=0;
8611
8612 switch(ndir)
8613 {
8614 case right:
8615 tile+=3;
8616 [[fallthrough]];
8617
8618 case left:
8619 tile+=3;
8620 [[fallthrough]];
8621
8622 case down:
8623 tile+=3;
8624 [[fallthrough]];
8625
8626 case up:
8627 break;
8628 }
8629 }
8630
8631 133804 void enemy::tiledir_small(int32_t ndir, bool fourdir)
8632 {
8633
1/2
✓ Branch 0 taken 133804 times.
✗ Branch 1 not taken.
133804 if ( !do_animation ) return;
8634 133804 flip=0;
8635
8636
8/9
✓ Branch 0 taken 27396 times.
✓ Branch 1 taken 27200 times.
✓ Branch 2 taken 35010 times.
✓ Branch 3 taken 36308 times.
✓ Branch 4 taken 2126 times.
✓ Branch 5 taken 1996 times.
✓ Branch 6 taken 2148 times.
✓ Branch 7 taken 1620 times.
✗ Branch 8 not taken.
133804 switch(ndir)
8637 {
8638 case 8:
8639 case up:
8640 27396 break;
8641
8642 case 12:
8643 case down:
8644 27200 tile+=2;
8645 27200 break;
8646
8647 case 14:
8648 case left:
8649 35010 tile+=4;
8650 35010 break;
8651
8652 case 10:
8653 case right:
8654 36308 tile+=6;
8655 36308 break;
8656
8657 case 9:
8658 case r_up:
8659
1/2
✓ Branch 0 taken 2126 times.
✗ Branch 1 not taken.
2126 if(fourdir)
8660 2126 break;
8661
8662 tile+=10;
8663 break;
8664
8665 case 11:
8666 case r_down:
8667
1/2
✓ Branch 0 taken 1996 times.
✗ Branch 1 not taken.
1996 if(fourdir)
8668 1996 tile+=2;
8669 else
8670 tile+=14;
8671
8672 1996 break;
8673
8674 case 13:
8675 case l_down:
8676
1/2
✓ Branch 0 taken 2148 times.
✗ Branch 1 not taken.
2148 if(fourdir)
8677 2148 tile+=2;
8678 else
8679 tile+=12;
8680
8681 2148 break;
8682
8683 case 15:
8684 case l_up:
8685
1/2
✓ Branch 0 taken 1620 times.
✗ Branch 1 not taken.
1620 if(fourdir)
8686 1620 break;
8687
8688 tile+=8;
8689 break;
8690
8691 default:
8692 //dir=(zc_oldrand()*100)%8;
8693 //tiledir_small(dir);
8694 // flip=zc_oldrand()&3;
8695 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8696 break;
8697 }
8698 133804 }
8699
8700 10360623 void enemy::tiledir(int32_t ndir, bool fourdir)
8701 {
8702
1/2
✓ Branch 0 taken 10360623 times.
✗ Branch 1 not taken.
10360623 if ( !do_animation ) return;
8703 10360623 flip=0;
8704
8705
9/9
✓ Branch 0 taken 2075292 times.
✓ Branch 1 taken 1794855 times.
✓ Branch 2 taken 2470737 times.
✓ Branch 3 taken 2375722 times.
✓ Branch 4 taken 371164 times.
✓ Branch 5 taken 447500 times.
✓ Branch 6 taken 434629 times.
✓ Branch 7 taken 382443 times.
✓ Branch 8 taken 8281 times.
10360623 switch(ndir)
8706 {
8707 case 8:
8708 case up:
8709 2075292 break;
8710
8711 case 12:
8712 case down:
8713 1794855 tile+=4;
8714 1794855 break;
8715
8716 case 14:
8717 case left:
8718 2470737 tile+=8;
8719 2470737 break;
8720
8721 case 10:
8722 case right:
8723 2375722 tile+=12;
8724 2375722 break;
8725
8726 case 9:
8727 case r_up:
8728
2/2
✓ Branch 0 taken 53890 times.
✓ Branch 1 taken 317274 times.
371164 if(fourdir)
8729 53890 break;
8730 else
8731 317274 tile+=24;
8732
8733 317274 break;
8734
8735 case 11:
8736 case r_down:
8737
2/2
✓ Branch 0 taken 58873 times.
✓ Branch 1 taken 388627 times.
447500 if(fourdir)
8738 58873 tile+=4;
8739 else
8740 388627 tile+=32;
8741
8742 447500 break;
8743
8744 case 13:
8745 case l_down:
8746
2/2
✓ Branch 0 taken 61462 times.
✓ Branch 1 taken 373167 times.
434629 if(fourdir)
8747 61462 tile+=4;
8748 else
8749 373167 tile+=28;
8750
8751 434629 break;
8752
8753 case 15:
8754 case l_up:
8755
2/2
✓ Branch 0 taken 46534 times.
✓ Branch 1 taken 335909 times.
382443 if(fourdir)
8756 46534 break;
8757 else
8758 335909 tile+=20;
8759
8760 335909 break;
8761
8762 default:
8763 //dir=(zc_oldrand()*100)%8;
8764 //tiledir(dir);
8765 // flip=zc_oldrand()&3;
8766 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8767 8281 break;
8768 }
8769 10360623 }
8770
8771 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
8772 {
8773
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
8774 3868 flip=0;
8775
8776
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
8777 {
8778 case 8:
8779 case up:
8780 297 break;
8781
8782 case 12:
8783 case down:
8784 tile+=8;
8785 break;
8786
8787 case 14:
8788 case left:
8789 195 tile+=40;
8790 195 break;
8791
8792 case 10:
8793 case right:
8794 179 tile+=48;
8795 179 break;
8796
8797 case 9:
8798 case r_up:
8799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
8800 break;
8801
8802 306 tile+=88;
8803 306 break;
8804
8805 case 11:
8806 case r_down:
8807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
8808 tile+=8;
8809 else
8810 1235 tile+=128;
8811
8812 1235 break;
8813
8814 case 13:
8815 case l_down:
8816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
8817 tile+=8;
8818 else
8819 1324 tile+=120;
8820
8821 1324 break;
8822
8823 case 15:
8824 case l_up:
8825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
8826 break;
8827
8828 332 tile+=80;
8829 332 break;
8830
8831 default:
8832 //dir=(zc_oldrand()*100)%8;
8833 //tiledir_big(dir);
8834 // flip=zc_oldrand()&3;
8835 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8836 break;
8837 }
8838 3868 }
8839
8840 20821319 void enemy::update_enemy_frame()
8841 {
8842
3/4
✓ Branch 0 taken 20821177 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20821177 times.
20821319 if(fallclk||drownclk) return;
8843
1/2
✓ Branch 0 taken 20821177 times.
✗ Branch 1 not taken.
20821177 if (!do_animation)
8844 return;
8845
8846
3/4
✓ Branch 0 taken 188014 times.
✓ Branch 1 taken 20633163 times.
✓ Branch 2 taken 188014 times.
✗ Branch 3 not taken.
20821177 if (get_bit(quest_rules,qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
8847
8848
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
20821177 if(get_bit(quest_rules,qr_ANONE_NOANIM)
8849
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20821177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20821177 && anim == aNONE && family != eeGUY)
8850 return;
8851
2/2
✓ Branch 0 taken 20481421 times.
✓ Branch 1 taken 339756 times.
20821177 int32_t newfrate = zc_max(frate,4);
8852 20821177 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
8853 20821177 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
8854
2/2
✓ Branch 0 taken 13522850 times.
✓ Branch 1 taken 7298327 times.
20821177 int32_t fx = get_bit(quest_rules, qr_NEWENEMYTILES) ? f4 : f2;
8855 20821177 tile = o_tile;
8856 20821177 int32_t basetile = o_tile;
8857 20821177 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
8858 20821177 bool ignore_extend = false;
8859
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 35552 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 207174 times.
✓ Branch 8 taken 125758 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2385244 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 48420 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 595734 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 401570 times.
✓ Branch 22 taken 1050131 times.
✓ Branch 23 taken 805337 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 133804 times.
✓ Branch 26 taken 1947001 times.
✓ Branch 27 taken 3438929 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1192460 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3146848 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 36233 times.
20821177 switch(anim)
8860 {
8861
8862 case aDONGO:
8863 {
8864 41139 int32_t fr = stunclk>0 ? 16 : 8;
8865
8866
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
8867 {
8868 // bloated
8869
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
8870 {
8871 case up:
8872 832 tile+=9;
8873 832 flip=0;
8874 832 xofs=0;
8875 832 dummy_int[1]=0; //no additional tiles
8876 832 break;
8877
8878 case down:
8879 448 tile+=7;
8880 448 flip=0;
8881 448 xofs=0;
8882 448 dummy_int[1]=0; //no additional tiles
8883 448 break;
8884
8885 case left:
8886 1152 flip=1;
8887 1152 tile+=4;
8888 1152 xofs=16;
8889 1152 dummy_int[1]=1; //second tile is next tile
8890 1152 break;
8891
8892 case right:
8893 768 flip=0;
8894 768 tile+=5;
8895 768 xofs=16;
8896 768 dummy_int[1]=-1; //second tile is previous tile
8897 768 break;
8898 }
8899 3200 }
8900
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
8901 {
8902 // normal
8903
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
8904 {
8905 case up:
8906 7974 tile+=8;
8907 7974 flip=(clk&fr)?1:0;
8908 7974 xofs=0;
8909 7974 dummy_int[1]=0; //no additional tiles
8910 7974 break;
8911
8912 case down:
8913 8400 tile+=6;
8914 8400 flip=(clk&fr)?1:0;
8915 8400 xofs=0;
8916 8400 dummy_int[1]=0; //no additional tiles
8917 8400 break;
8918
8919 case left:
8920 12214 flip=1;
8921 12214 tile+=(clk&fr)?2:0;
8922 12214 xofs=16;
8923 12214 dummy_int[1]=1; //second tile is next tile
8924 12214 break;
8925
8926 case right:
8927 8568 flip=0;
8928 8568 tile+=(clk&fr)?3:1;
8929 8568 xofs=16;
8930 8568 dummy_int[1]=-1; //second tile is next tile
8931 8568 break;
8932 }
8933 37156 }
8934 }
8935 41139 break;
8936
8937 case aNEWDONGO:
8938 {
8939 48420 int32_t fr4=0;
8940
8941
6/6
✓ Branch 0 taken 46728 times.
✓ Branch 1 taken 1692 times.
✓ Branch 2 taken 3648 times.
✓ Branch 3 taken 43080 times.
✓ Branch 4 taken 1216 times.
✓ Branch 5 taken 2432 times.
48420 if(!dying && clk2>0 && clk2<=64)
8942 {
8943 // bloated
8944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 if(clk2>=0)
8945 {
8946 2432 fr4=3;
8947 2432 }
8948
8949
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 1862 times.
2432 if(clk2>=16)
8950 {
8951 1862 fr4=2;
8952 1862 }
8953
8954
2/2
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 1254 times.
2432 if(clk2>=32)
8955 {
8956 1254 fr4=1;
8957 1254 }
8958
8959
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 646 times.
2432 if(clk2>=48)
8960 {
8961 646 fr4=0;
8962 646 }
8963
8964
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1024 times.
2432 switch(dir)
8965 {
8966 case up:
8967 256 xofs=0;
8968 256 tile+=8+fr4;
8969 256 dummy_int[1]=0; //no additional tiles
8970 256 break;
8971
8972 case down:
8973 576 xofs=0;
8974 576 tile+=12+fr4;
8975 576 dummy_int[1]=0; //no additional tiles
8976 576 break;
8977
8978 case left:
8979 576 tile+=29+(2*fr4);
8980 576 xofs=16;
8981 576 dummy_int[1]=-1; //second tile is previous tile
8982 576 break;
8983
8984 case right:
8985 1024 tile+=49+(2*fr4);
8986 1024 xofs=16;
8987 1024 dummy_int[1]=-1; //second tile is previous tile
8988 1024 break;
8989 }
8990 2432 }
8991
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 44296 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 769 times.
45988 else if(!dying || clk2>19)
8992 {
8993 // normal
8994
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8569 times.
✓ Branch 2 taken 8925 times.
✓ Branch 3 taken 13235 times.
✓ Branch 4 taken 14490 times.
45219 switch(dir)
8995 {
8996 case up:
8997 8569 xofs=0;
8998 8569 tile+=((clk&12)>>2);
8999 8569 dummy_int[1]=0; //no additional tiles
9000 8569 break;
9001
9002 case down:
9003 8925 xofs=0;
9004 8925 tile+=4+((clk&12)>>2);
9005 8925 dummy_int[1]=0; //no additional tiles
9006 8925 break;
9007
9008 case left:
9009 13235 tile+=21+((clk&12)>>1);
9010 13235 xofs=16;
9011 13235 dummy_int[1]=-1; //second tile is previous tile
9012 13235 break;
9013
9014 case right:
9015 14490 flip=0;
9016 14490 tile+=41+((clk&12)>>1);
9017 14490 xofs=16;
9018 14490 dummy_int[1]=-1; //second tile is previous tile
9019 14490 break;
9020 }
9021 45219 }
9022 }
9023 48420 break;
9024
9025 case aDONGOBS:
9026 {
9027 818 int32_t fr4=0;
9028
9029
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
9030 {
9031 // bloated
9032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
9033 {
9034 128 fr4=3;
9035 128 }
9036
9037
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
9038 {
9039 98 fr4=2;
9040 98 }
9041
9042
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
9043 {
9044 66 fr4=1;
9045 66 }
9046
9047
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
9048 {
9049 34 fr4=0;
9050 34 }
9051
9052
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
9053 {
9054 case up:
9055 tile+=28+fr4;
9056 yofs+=8;
9057 dummy_int[1]=-20; //second tile change
9058 dummy_int[2]=0; //new xofs change
9059 dummy_int[3]=-16; //new xofs change
9060 break;
9061
9062 case down:
9063 tile+=12+fr4;
9064 yofs-=8;
9065 dummy_int[1]=20; //second tile change
9066 dummy_int[2]=0; //new xofs change
9067 dummy_int[3]=16; //new xofs change
9068 break;
9069
9070 case left:
9071 128 tile+=49+(2*fr4);
9072 128 xofs+=8;
9073 128 dummy_int[1]=-1; //second tile change
9074 128 dummy_int[2]=-16; //new xofs change
9075 128 dummy_int[3]=0; //new xofs change
9076 128 break;
9077
9078 case right:
9079 tile+=69+(2*fr4);
9080 xofs+=8;
9081 dummy_int[1]=-1; //second tile change
9082 dummy_int[2]=-16; //new xofs change
9083 dummy_int[3]=0; //new xofs change
9084 break;
9085 }
9086 128 }
9087
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
9088 {
9089 // normal
9090
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
9091 {
9092 case up:
9093 96 tile+=20+((clk&24)>>3);
9094 96 yofs+=8;
9095 96 dummy_int[1]=-20; //second tile change
9096 96 dummy_int[2]=0; //new xofs change
9097 96 dummy_int[3]=-16; //new xofs change
9098 96 break;
9099
9100 case down:
9101 129 tile+=4+((clk&24)>>3);
9102 129 yofs-=8;
9103 129 dummy_int[1]=20; //second tile change
9104 129 dummy_int[2]=0; //new xofs change
9105 129 dummy_int[3]=16; //new xofs change
9106 129 break;
9107
9108 case left:
9109 332 xofs=-8;
9110 332 tile+=40+((clk&24)>>2);
9111 332 dummy_int[1]=1; //second tile change
9112 332 dummy_int[2]=16; //new xofs change
9113 332 dummy_int[3]=0; //new xofs change
9114 332 break;
9115
9116 case right:
9117 97 tile+=60+((clk&24)>>2);
9118 97 xofs=-8;
9119 97 dummy_int[1]=1; //second tile change
9120 97 dummy_int[2]=16; //new xofs change
9121 97 dummy_int[3]=0; //new xofs change
9122 97 break;
9123 }
9124 654 }
9125 }
9126 818 break;
9127
9128 case aWIZZ:
9129 {
9130 // if(d->misc1)
9131
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
9132 {
9133
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
9134 {
9135 69773 ++tile;
9136 69773 }
9137 139048 }
9138 else
9139 {
9140
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
9141 {
9142 107176 ++tile;
9143 107176 }
9144 }
9145
9146
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
9147 {
9148 case 9:
9149 case 15:
9150 case up:
9151 55328 tile+=2;
9152 55328 break;
9153
9154 case down:
9155 59335 break;
9156
9157 case 13:
9158 case left:
9159 124116 flip=1;
9160 124116 break;
9161
9162 default:
9163 114795 flip=0;
9164 114795 break;
9165 }
9166 }
9167 353574 break;
9168
9169 case aNEWWIZZ:
9170 {
9171 595734 tiledir(dir,true);
9172
9173 // if(d->misc1) //walking wizzrobe
9174
2/2
✓ Branch 0 taken 316790 times.
✓ Branch 1 taken 278944 times.
595734 if(dmisc1) //walking wizzrobe
9175 {
9176
2/2
✓ Branch 0 taken 159200 times.
✓ Branch 1 taken 157590 times.
316790 if(clk&8)
9177 {
9178 157590 tile+=2;
9179 157590 }
9180
9181
2/2
✓ Branch 0 taken 158616 times.
✓ Branch 1 taken 158174 times.
316790 if(clk&4)
9182 {
9183 158174 tile+=1;
9184 158174 }
9185
9186
2/4
✓ Branch 0 taken 316790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 316790 times.
316790 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
9187 {
9188
2/2
✓ Branch 0 taken 283104 times.
✓ Branch 1 taken 33686 times.
316790 if(dummy_int[1]>0)
9189 {
9190 33686 tile+=40;
9191 33686 }
9192 316790 }
9193 316790 }
9194 else
9195 {
9196
4/4
✓ Branch 0 taken 255725 times.
✓ Branch 1 taken 23219 times.
✓ Branch 2 taken 59829 times.
✓ Branch 3 taken 195896 times.
278944 if(dummy_bool[1]||dummy_bool[2])
9197 {
9198 83048 tile+=20;
9199
9200
2/2
✓ Branch 0 taken 23219 times.
✓ Branch 1 taken 59829 times.
83048 if(dummy_bool[2])
9201 {
9202 59829 tile+=20;
9203 59829 }
9204 83048 }
9205
9206 278944 tile+=((frame>>1)&3);
9207 }
9208 }
9209 595734 break;
9210
9211 case a3FRM:
9212 {
9213
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
9214 }
9215 163042 break;
9216
9217 case a3FRM4DIR:
9218 {
9219 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
9220 }
9221 break;
9222
9223 case aVIRE:
9224 {
9225
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
9226 {
9227 22222 tile+=2;
9228 22222 }
9229
9230 98223 tile+=fx;
9231 }
9232 98223 break;
9233
9234 case aROPE:
9235 {
9236 164903 tile+=(1-fx);
9237 164903 flip = dir==left ? 1:0;
9238 }
9239 164903 break;
9240
9241 case aZORA:
9242 {
9243 int32_t dl;
9244
9245
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
9246 {
9247 33018 dl=clk+5;
9248 33018 goto waves2;
9249 }
9250
9251
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
9252
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
9253 else
9254 {
9255 65898 dl=clk-36-66;
9256 waves2:
9257 98916 tile=((dl/11)&1)+s_tile;
9258 98916 basetile = s_tile;
9259 }
9260 }
9261 157529 break;
9262
9263 case aNEWZORA:
9264 {
9265 401570 f4=(clk/16)%4;
9266
9267 401570 tiledir(dir,true);
9268 int32_t dl;
9269
9270
4/4
✓ Branch 0 taken 289179 times.
✓ Branch 1 taken 112391 times.
✓ Branch 2 taken 151547 times.
✓ Branch 3 taken 137632 times.
401570 if((clk>35)&&(clk<36+67)) //surfaced
9271 {
9272
4/4
✓ Branch 0 taken 117577 times.
✓ Branch 1 taken 20055 times.
✓ Branch 2 taken 16796 times.
✓ Branch 3 taken 100781 times.
137632 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
9273 {
9274 100781 tile+=80;
9275 100781 } //mouth closed
9276 else
9277 {
9278 36851 tile+=40;
9279 }
9280
9281 137632 tile+=f4;
9282 137632 }
9283 else
9284 {
9285
2/2
✓ Branch 0 taken 112391 times.
✓ Branch 1 taken 151547 times.
263938 if(clk<36)
9286 {
9287 112391 dl=clk+5;
9288 112391 }
9289 else
9290 {
9291 151547 dl=clk-36-66;
9292 }
9293
9294 263938 tile+=((dl/5)&3);
9295 }
9296 }
9297 401570 break;
9298
9299 case a4FRM4EYE:
9300 case a2FRM4EYE:
9301 case a4FRM8EYE:
9302 case a4FRM8EYEB: //big version
9303 case a4FRM4EYEB:
9304 {
9305 125758 tilerows = 2;
9306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakex = x + 8*(zc_max(1,txsz)-1);
9307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakey = y + 8*(zc_max(1,tysz)-1);
9308 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9309 125758 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
9310 125758 int32_t lookat=zc_oldrand()&15;
9311
9312
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 84804 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
125758 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
9313 {
9314 20770 lookat=l_down;
9315 20770 }
9316
4/4
✓ Branch 0 taken 41154 times.
✓ Branch 1 taken 63834 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20970 times.
104988 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
9317 {
9318 20970 lookat=down;
9319 20970 }
9320
4/4
✓ Branch 0 taken 33302 times.
✓ Branch 1 taken 50716 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13118 times.
84018 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
9321 {
9322 13118 lookat=r_down;
9323 13118 }
9324
4/4
✓ Branch 0 taken 31638 times.
✓ Branch 1 taken 39262 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11454 times.
70900 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
9325 {
9326 11454 lookat=right;
9327 11454 }
9328
4/4
✓ Branch 0 taken 24538 times.
✓ Branch 1 taken 34908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4354 times.
59446 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
9329 {
9330 4354 lookat=r_up;
9331 4354 }
9332
4/4
✓ Branch 0 taken 25602 times.
✓ Branch 1 taken 29490 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5418 times.
55092 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
9333 {
9334 5418 lookat=up;
9335 5418 }
9336
4/4
✓ Branch 0 taken 29766 times.
✓ Branch 1 taken 19908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 9582 times.
49674 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
9337 {
9338 9582 lookat=l_up;
9339 9582 }
9340 else
9341 {
9342 40092 lookat=left;
9343 }
9344
9345 125758 int32_t dir2 = dir;
9346 125758 dir = lookat;
9347
3/6
✓ Branch 0 taken 125758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125758 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125758 times.
125758 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
9348 else
9349 {
9350 tiledir_big(dir,(anim == a4FRM4EYEB));
9351 tile+=2*f4;
9352 ignore_extend = true;
9353 }
9354 125758 dir = dir2;
9355 }
9356 125758 break;
9357
9358 case aFLIP:
9359 {
9360 1050131 flip = f2&1;
9361 }
9362 1050131 break;
9363
9364 case a2FRM:
9365 {
9366 805337 tile += (1-f2);
9367 }
9368 805337 break;
9369
9370 case a2FRMB:
9371 {
9372 tile+= 2*(1-f2);
9373 ignore_extend = true;
9374 }
9375 break;
9376
9377 case a2FRM4DIR:
9378 {
9379 133804 basetile = n_frame_n_dir(2, 4, f2&1);
9380 }
9381 133804 break;
9382
9383 case a4FRM4DIRF:
9384 {
9385 1947001 basetile = n_frame_n_dir(4,4,f4);
9386
9387
2/2
✓ Branch 0 taken 1242623 times.
✓ Branch 1 taken 704378 times.
1947001 if(clk2>0) //stopped to fire
9388 {
9389 704378 tile+=20;
9390
9391
2/2
✓ Branch 0 taken 337123 times.
✓ Branch 1 taken 367255 times.
704378 if(clk2<17) //firing
9392 {
9393 367255 tile+=20;
9394 367255 }
9395 704378 }
9396 }
9397 1947001 break;
9398
9399 case a4FRM4DIR:
9400 {
9401 3438929 basetile = n_frame_n_dir(4,4,f4);
9402 }
9403 3438929 break;
9404
9405 case a4FRM8DIRF:
9406 {
9407 tilerows = 2;
9408 basetile = n_frame_n_dir(4,8,f4);
9409
9410 if(clk2>0) //stopped to fire
9411 {
9412 tile+=40;
9413
9414 if(clk2<17) //firing
9415 {
9416 tile+=40;
9417 }
9418 }
9419 }
9420 break;
9421
9422 case a4FRM8DIRB:
9423 case a4FRM8DIRFB:
9424 {
9425 3868 tilerows = 2;
9426 3868 tiledir_big(dir,false);
9427 3868 tile+=2*f4;
9428
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
9429 {
9430 tile+=80;
9431
9432 if(clk2<17) //firing
9433 {
9434 tile+=80;
9435 }
9436 }
9437 3868 ignore_extend = true;
9438 }
9439 3868 break;
9440
9441 case a4FRM4DIRB:
9442 case a4FRM4DIRFB:
9443 {
9444 tilerows = 2;
9445 tiledir_big(dir,true);
9446 tile+=2*f4;
9447 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
9448 {
9449 tile+=40;
9450
9451 if(clk2<17) //firing
9452 {
9453 tile+=40;
9454 }
9455 }
9456 ignore_extend = true;
9457 }
9458 break;
9459
9460 case aOCTO:
9461 {
9462
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
9463 {
9464 case up:
9465 85458 flip = 2;
9466 85458 break;
9467
9468 case down:
9469 96229 flip = 0;
9470 96229 break;
9471
9472 case left:
9473 112826 flip = 0;
9474 112826 tile += 2;
9475 112826 break;
9476
9477 case right:
9478 101887 flip = 1;
9479 101887 tile += 2;
9480 101887 break;
9481 }
9482
9483 399313 tile+=f2;
9484 }
9485 399313 break;
9486
9487 case aWALK:
9488 {
9489
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
9490 {
9491 case up:
9492 187339 tile+=3;
9493 187339 flip = f2;
9494 187339 break;
9495
9496 case down:
9497 207694 tile+=2;
9498 207694 flip = f2;
9499 207694 break;
9500
9501 case left:
9502 256906 flip=1;
9503 256906 tile += f2;
9504 256906 break;
9505
9506 case right:
9507 256215 flip=0;
9508 256215 tile += f2;
9509 256215 break;
9510 }
9511 }
9512 912736 break;
9513
9514 case aDWALK:
9515 {
9516
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_bit(quest_rules,qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
9517 {
9518 tile=s_tile;
9519 basetile = s_tile;
9520 }
9521
9522
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
9523 {
9524 case up:
9525 129268 tile+=2;
9526 129268 flip=f2;
9527 129268 break;
9528
9529 case down:
9530 133261 flip=0;
9531 133261 tile+=(1-f2);
9532 133261 break;
9533
9534 case left:
9535 177242 flip=1;
9536 177242 tile+=(3+f2);
9537 177242 break;
9538
9539 case right:
9540 174880 flip=0;
9541 174880 tile+=(3+f2);
9542 174880 break;
9543 }
9544 }
9545 614651 break;
9546
9547 case aTEK:
9548 {
9549
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
9550 {
9551 60556 tile += f2;
9552 60556 }
9553
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
9554 {
9555 47418 ++tile;
9556 47418 }
9557 }
9558 161932 break;
9559
9560 case aNEWTEK:
9561 {
9562
2/2
✓ Branch 0 taken 300110 times.
✓ Branch 1 taken 892350 times.
1192460 if(step<0) //up
9563 {
9564
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147188 times.
✓ Branch 2 taken 152922 times.
300110 switch(clk3)
9565 {
9566 case left:
9567 147188 flip=0;
9568 147188 tile+=20;
9569 147188 break;
9570
9571 case right:
9572 152922 flip=0;
9573 152922 tile+=24;
9574 152922 break;
9575 }
9576 300110 }
9577
2/2
✓ Branch 0 taken 38134 times.
✓ Branch 1 taken 854216 times.
892350 else if(step==0)
9578 {
9579
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28779 times.
✓ Branch 2 taken 9355 times.
38134 switch(clk3)
9580 {
9581 case left:
9582 28779 flip=0;
9583 28779 tile+=8;
9584 28779 break;
9585
9586 case right:
9587 9355 flip=0;
9588 9355 tile+=12;
9589 9355 break;
9590 }
9591 38134 } //down
9592 else
9593 {
9594
3/3
✓ Branch 0 taken 55883 times.
✓ Branch 1 taken 403592 times.
✓ Branch 2 taken 394741 times.
854216 switch(clk3)
9595 {
9596 case left:
9597 403592 flip=0;
9598 403592 tile+=28;
9599 403592 break;
9600
9601 case right:
9602 394741 flip=0;
9603 394741 tile+=32;
9604 394741 break;
9605 }
9606 }
9607
9608
2/2
✓ Branch 0 taken 757747 times.
✓ Branch 1 taken 434713 times.
1192460 if(misc==0)
9609 {
9610 434713 tile+=f4;
9611 434713 }
9612
2/2
✓ Branch 0 taken 367826 times.
✓ Branch 1 taken 389921 times.
757747 else if(misc!=1)
9613 {
9614 389921 tile+=2;
9615 389921 }
9616 }
9617 1192460 break;
9618
9619 case aARMOS:
9620 {
9621
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
9622 {
9623 3306 tile += fx;
9624
9625
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
9626 847 tile += 2;
9627 3306 }
9628 }
9629 5459 break;
9630
9631 case aARMOS4:
9632 {
9633
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5907 times.
✓ Branch 2 taken 12136 times.
✓ Branch 3 taken 8764 times.
✓ Branch 4 taken 8745 times.
35552 switch(dir)
9634 {
9635 case up:
9636 5907 flip=0;
9637 5907 break;
9638
9639 case down:
9640 12136 flip=0;
9641 12136 tile+=4;
9642 12136 break;
9643
9644 case left:
9645 8764 flip=0;
9646 8764 tile+=8;
9647 8764 break;
9648
9649 case right:
9650 8745 flip=0;
9651 8745 tile+=12;
9652 8745 break;
9653 }
9654
9655
2/2
✓ Branch 0 taken 6441 times.
✓ Branch 1 taken 29111 times.
35552 if(!fading)
9656 {
9657 29111 tile+=f4;
9658 29111 }
9659 }
9660 35552 break;
9661
9662 case aGHINI:
9663 {
9664
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
9665 {
9666 case 8:
9667 case 9:
9668 case up:
9669 14931 ++tile;
9670 14931 flip=0;
9671 14931 break;
9672
9673 case 15:
9674 374 ++tile;
9675 374 flip=1;
9676 374 break;
9677
9678 case 10:
9679 case 11:
9680 case right:
9681 18961 flip=1;
9682 18961 break;
9683
9684 default:
9685 40404 flip=0;
9686 40404 break;
9687 }
9688 }
9689 74670 break;
9690
9691 case a2FRMPOS:
9692 {
9693 1313148 tile+=posframe;
9694 }
9695 1313148 break;
9696
9697 case a4FRMPOS4DIR:
9698 {
9699 216057 basetile = n_frame_n_dir(4,4,0);
9700 // tile+=f2;
9701 216057 tile+=posframe;
9702 }
9703 216057 break;
9704
9705 case a4FRMPOS4DIRF:
9706 {
9707 basetile = n_frame_n_dir(4,4,0);
9708
9709 if(clk2>0) //stopped to fire
9710 {
9711 tile+=20;
9712
9713 if(clk2<17) //firing
9714 {
9715 tile+=20;
9716 }
9717 }
9718
9719 // tile+=f2;
9720 tile+=posframe;
9721 }
9722 break;
9723
9724 case a4FRMPOS8DIR:
9725 {
9726 3146848 tilerows = 2;
9727 3146848 int32_t n = tile;
9728 3146848 basetile = n_frame_n_dir(4,8,0);
9729 // tile+=f2;
9730 3146848 tile+=posframe;
9731 }
9732 3146848 break;
9733
9734 case a4FRMPOS8DIRF:
9735 {
9736 tilerows = 2;
9737 basetile = n_frame_n_dir(4,8,0);
9738
9739 if(clk2>0) //stopped to fire
9740 {
9741 tile+=40;
9742
9743 if(clk2<17) //firing
9744 {
9745 tile+=40;
9746 }
9747 }
9748
9749 tile+=posframe;
9750 }
9751 break;
9752
9753 case aNEWLEV:
9754 {
9755 281552 tiledir(dir,true);
9756
9757
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
9758 {
9759 case -1:
9760 case 0:
9761 92775 return;
9762
9763 case 1:
9764
9765 // case 5: cs = d->misc2; break;
9766 case 5:
9767 45501 cs = dmisc2;
9768 45501 break;
9769
9770 case 2:
9771 case 4:
9772 18315 tile += 20;
9773 18315 break;
9774
9775 case 3:
9776 124961 tile += 40;
9777 124961 break;
9778 }
9779
9780 188777 tile+=f4;
9781 }
9782 188777 break;
9783
9784 case aLEV:
9785 {
9786 219227 f4 = ((clk/5)&1);
9787
9788
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
9789 {
9790 case -1:
9791 case 0:
9792 106859 return;
9793
9794 case 1:
9795
9796 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
9797 case 5:
9798 24845 tile += (f2) ? 1 : 0;
9799 24845 cs = dmisc2;
9800 24845 break;
9801
9802 case 2:
9803 case 4:
9804 11238 tile += 2;
9805 11238 break;
9806
9807 case 3:
9808 76285 tile += (f4) ? 4 : 3;
9809 76285 break;
9810 }
9811 }
9812 112368 break;
9813
9814 case aWALLM:
9815 {
9816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
9817 {
9818 89141 tile += f2;
9819 89141 }
9820 }
9821 89141 break;
9822
9823 case aNEWWALLM:
9824 {
9825 207174 int32_t tempdir=0;
9826
9827
4/4
✓ Branch 0 taken 27129 times.
✓ Branch 1 taken 20687 times.
✓ Branch 2 taken 5822 times.
✓ Branch 3 taken 153536 times.
207174 switch(misc)
9828 {
9829 case 1:
9830 case 2:
9831 20687 tempdir=clk3;
9832 20687 break;
9833
9834 case 3:
9835 case 4:
9836 case 5:
9837 27129 tempdir=dir;
9838 27129 break;
9839
9840 case 6:
9841 case 7:
9842 5822 tempdir=clk3^1;
9843 5822 break;
9844 }
9845
9846 207174 tiledir(tempdir,true);
9847
9848
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 206596 times.
207174 if(!dummy_bool[1])
9849 {
9850 206596 tile+=f4;
9851 206596 }
9852 }
9853 207174 break;
9854
9855 case a4FRMNODIR:
9856 {
9857 36233 tile+=f4;
9858 }
9859 36233 break;
9860
9861 } // switch(d->anim)
9862
9863 // flashing
9864 // if(d->flags2 & guy_flashing)
9865
2/2
✓ Branch 0 taken 20112612 times.
✓ Branch 1 taken 508931 times.
20621543 if(flags2 & guy_flashing)
9866 {
9867 508931 cs = (frame&3) + 6;
9868 508931 }
9869
9870
2/2
✓ Branch 0 taken 20589429 times.
✓ Branch 1 taken 32114 times.
20621543 if(flags2&guy_transparent)
9871 {
9872 32114 drawstyle=1;
9873 32114 }
9874
9875 20621543 int32_t change = tile-basetile;
9876
9877
3/6
✓ Branch 0 taken 530368 times.
✓ Branch 1 taken 20091175 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 530368 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20621543 if(extend > 2 && (!ignore_extend || get_bit(quest_rules, qr_BROKEN_BIG_ENEMY_ANIMATION)))
9878 {
9879
2/2
✓ Branch 0 taken 486406 times.
✓ Branch 1 taken 43962 times.
530368 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
9880 {
9881 486406 tile=basetile+txsz*change;
9882 486406 }
9883 else
9884 {
9885 43962 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
9886 }
9887 530368 }
9888 else
9889 {
9890 20091175 tile=basetile+change;
9891 }
9892 20821319 }
9893
9894 51050 int32_t wpnsfx(int32_t wpn)
9895 {
9896
5/6
✓ Branch 0 taken 17448 times.
✓ Branch 1 taken 283 times.
✓ Branch 2 taken 17447 times.
✓ Branch 3 taken 10387 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5485 times.
51050 switch(wpn)
9897 {
9898 case ewFireTrail:
9899 case ewFlame:
9900 case ewFlame2Trail:
9901 case ewFlame2:
9902 17448 return WAV_FIRE;
9903
9904 case ewWind:
9905 case ewMagic:
9906 283 return WAV_WAND;
9907
9908 case ewIce:
9909 return WAV_ZN1ICE;
9910
9911 case ewRock:
9912
2/2
✓ Branch 0 taken 5221 times.
✓ Branch 1 taken 264 times.
5485 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1ROCK;
9913 5221 break;
9914
9915 case ewFireball2:
9916 case ewFireball:
9917
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 17440 times.
17447 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
9918 17440 }
9919
9920 33048 return -1;
9921 51050 }
9922
9923 39070697 int32_t enemy::run_script(int32_t mode)
9924 {
9925
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39070697 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39070697 if(switch_hooked && !get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
9926
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 39070697 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
39070697 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
9927 39070697 return RUNSCRIPT_OK;
9928 int32_t ret = RUNSCRIPT_OK;
9929 alloc_scriptmem();
9930 switch(mode)
9931 {
9932 case MODE_NORMAL:
9933 return ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9934 case MODE_WAITDRAW:
9935 if(waitdraw)
9936 {
9937 ret = ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9938 waitdraw = 0;
9939 }
9940 break;
9941 }
9942 return ret;
9943 39070697 }
9944 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
9945 {
9946 return al_map_rgba(255,0,0,opacity);
9947 }
9948 /********************************/
9949 /********* Guy Class **********/
9950 /********************************/
9951
9952 // good guys, fires, fairy, and other non-enemies
9953 // based on enemy class b/c guys in dungeons act sort of like enemies
9954 // also easier to manage all the guys this way
9955 2582 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
9956 2582 {
9957 1291 mainguy=mg;
9958 1291 canfreeze=false;
9959 1291 dir=down;
9960
3/6
✓ Branch 0 taken 1291 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291 times.
✓ Branch 4 taken 1291 times.
✗ Branch 5 not taken.
1291 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9961 1291 hxofs=2;
9962 1291 hzsz=8;
9963 1291 hxsz=12;
9964 1291 hysz=17;
9965
9966
10/12
✓ Branch 0 taken 1291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1291 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 403 times.
✓ Branch 5 taken 888 times.
✓ Branch 6 taken 393 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 148 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 134 times.
1291 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
9967 {
9968 1157 superman = 1;
9969 1157 hxofs=1000;
9970 1157 }
9971 1291 }
9972
9973 485101 bool guy::animate(int32_t index)
9974 {
9975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 485101 times.
485101 if(switch_hooked) return enemy::animate(index);
9976
6/6
✓ Branch 0 taken 193176 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 1752 times.
✓ Branch 3 taken 191424 times.
✓ Branch 4 taken 1184 times.
✓ Branch 5 taken 568 times.
485101 if(mainguy && clk==0 && misc==0)
9977 {
9978 568 setupscreen();
9979 568 misc = 1;
9980 568 }
9981
9982
4/4
✓ Branch 0 taken 193176 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 192989 times.
✓ Branch 3 taken 187 times.
485101 if(mainguy && fadeclk==0)
9983 187 return true;
9984
9985 484914 hp=256; // good guys never die...
9986
9987
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 484830 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 3 times.
484914 if(hclk && !clk2)
9988 {
9989 // but if they get hit...
9990 3 ++clk2; // only do this once
9991
9992
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(!get_bit(quest_rules,qr_NOGUYFIRES))
9993 {
9994 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
9995 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
9996 1 }
9997 3 }
9998
9999 484914 return enemy::animate(index);
10000 485101 }
10001
10002 488251 void guy::draw(BITMAP *dest)
10003 {
10004 488251 update_enemy_frame();
10005
10006
6/6
✓ Branch 0 taken 196198 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 12593 times.
✓ Branch 3 taken 183605 times.
✓ Branch 4 taken 6295 times.
✓ Branch 5 taken 6298 times.
488251 if(!mainguy || fadeclk<0 || fadeclk&1)
10007 481953 enemy::draw(dest);
10008 488251 }
10009
10010 /*******************************/
10011 /********* Enemies *********/
10012 /*******************************/
10013
10014 462 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10015 462 {
10016 231 clk4=0;
10017 231 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10018 // Spawn type
10019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
231 if(flags & guy_fadeflicker)
10020 {
10021 clk=0;
10022 superman = 1;
10023 fading=fade_flicker;
10024 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10025 dir=down;
10026
10027 if(!canmove(down,(zfix)8,spw_none,false))
10028 clk3=int32_t(13.0/step);
10029 }
10030
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 else if(flags & guy_fadeinstant)
10031 {
10032 clk=0;
10033 }
10034 231 SIZEflags = d->SIZEflags;
10035
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
231 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10036 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10037 // al_trace("Enemy txsz:%i\n", txsz);
10038
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
231 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10040
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
231 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10042
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10043
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10044 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10045
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10047 {
10048 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10049 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10050 }
10051
10052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 231 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
231 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
10053 231 }
10054
10055 57473 bool eFire::animate(int32_t index)
10056 {
10057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57473 times.
57473 if(switch_hooked) return enemy::animate(index);
10058
2/4
✓ Branch 0 taken 57473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57473 times.
57473 if(fallclk||drownclk) return enemy::animate(index);
10059
2/2
✓ Branch 0 taken 57078 times.
✓ Branch 1 taken 395 times.
57473 if(fading)
10060 {
10061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
395 if(++clk4 > 60)
10062 {
10063 clk4=0;
10064 superman=0;
10065 fading=0;
10066
10067 if(flags2&cmbflag_armos && z==0 && fakez==0)
10068 removearmos(x,y,ffcactivated);
10069
10070 clk2=0;
10071
10072 if(!canmove(down,(zfix)8,spw_none,false))
10073 {
10074 dir=0;
10075 y = y.getInt() & 0xF0;
10076 }
10077
10078 return Dead(index);
10079 }
10080
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 395 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
395 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10081 removearmos(x,y,ffcactivated);
10082 395 }
10083
10084 57473 return enemy::animate(index);
10085 57473 }
10086
10087 120986 void eFire::draw(BITMAP *dest)
10088 {
10089 120986 update_enemy_frame();
10090 120986 enemy::draw(dest);
10091 120986 }
10092
10093 119 int32_t eFire::takehit(weapon *w, weapon* realweap)
10094 {
10095 119 int32_t wpnId = w->id;
10096 119 int32_t wpnDir = w->dir;
10097
10098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10099 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10100 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10101 {
10102 shield = false;
10103 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10104
10105 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10106 o_tile=s_tile;
10107 }
10108
10109 119 int32_t ret = enemy::takehit(w,realweap);
10110 119 return ret;
10111 }
10112
10113 void eFire::break_shield()
10114 {
10115 if(!shield)
10116 return;
10117
10118 flags&=~(inv_front | inv_back | inv_left | inv_right);
10119 shield=false;
10120
10121 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10122 o_tile=s_tile;
10123 }
10124
10125 3570 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10126 3570 {
10127 //zprint2("npct other::other\n");
10128 1785 clk4=0;
10129 1785 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10130
10131 // Spawn type
10132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
1785 if(flags & guy_fadeflicker)
10133 {
10134 clk=0;
10135 superman = 1;
10136 fading=fade_flicker;
10137 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10138 dir=down;
10139
10140 if(!canmove(down,(zfix)8,spw_none,false))
10141 clk3=int32_t(13.0/step);
10142 }
10143
2/2
✓ Branch 0 taken 1761 times.
✓ Branch 1 taken 24 times.
1785 else if(flags & guy_fadeinstant)
10144 {
10145 24 clk=0;
10146 24 }
10147 1785 SIZEflags = d->SIZEflags;
10148
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1785 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10149 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10150 // al_trace("Enemy txsz:%i\n", txsz);
10151
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1785 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10152
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1785 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1785 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1785 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10155
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10156
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10157 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1785 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
1785 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10160 {
10161 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10162 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10163 }
10164
10165
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1785 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10166 1785 }
10167
10168 468746 bool eOther::animate(int32_t index)
10169 {
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 468746 times.
468746 if(switch_hooked) return enemy::animate(index);
10171
2/4
✓ Branch 0 taken 468746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 468746 times.
468746 if(fallclk||drownclk) return enemy::animate(index);
10172 //zprint2("npct other::animate\n");
10173
2/2
✓ Branch 0 taken 468521 times.
✓ Branch 1 taken 225 times.
468746 if(fading)
10174 {
10175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
225 if(++clk4 > 60)
10176 {
10177 clk4=0;
10178 superman=0;
10179 fading=0;
10180
10181 if(flags2&cmbflag_armos && z==0 && fakez==0)
10182 removearmos(x,y,ffcactivated);
10183
10184 clk2=0;
10185
10186 if(!canmove(down,(zfix)8,spw_none,false))
10187 {
10188 dir=0;
10189 y = y.getInt() & 0xF0;
10190 }
10191
10192 return Dead(index);
10193 }
10194
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
225 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10195 removearmos(x,y,ffcactivated);
10196 225 }
10197
10198 468746 return enemy::animate(index);
10199 468746 }
10200
10201 487056 void eOther::draw(BITMAP *dest)
10202 {
10203 487056 update_enemy_frame();
10204 487056 enemy::draw(dest);
10205 487056 }
10206
10207 3048 int32_t eOther::takehit(weapon *w, weapon* realweap)
10208 {
10209 3048 int32_t wpnId = w->id;
10210 3048 int32_t wpnDir = w->dir;
10211
10212
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3031 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
3048 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10213 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10214 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10215 {
10216 shield = false;
10217 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10218
10219 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10220 o_tile=s_tile;
10221 }
10222
10223 3048 int32_t ret = enemy::takehit(w,realweap);
10224 3048 return ret;
10225 }
10226
10227 void eOther::break_shield()
10228 {
10229 if(!shield)
10230 return;
10231
10232 flags&=~(inv_front | inv_back | inv_left | inv_right);
10233 shield=false;
10234
10235 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10236 o_tile=s_tile;
10237 }
10238
10239
10240 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10241 {
10242 clk4=0;
10243 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10244
10245 // Spawn type
10246 if(flags & guy_fadeflicker)
10247 {
10248 clk=0;
10249 superman = 1;
10250 fading=fade_flicker;
10251 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10252 dir=down;
10253
10254 if(!canmove(down,(zfix)8,spw_none,false))
10255 clk3=int32_t(13.0/step);
10256 }
10257 else if(flags & guy_fadeinstant)
10258 {
10259 clk=0;
10260 }
10261 SIZEflags = d->SIZEflags;
10262 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10263 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10264 // al_trace("Enemy txsz:%i\n", txsz);
10265 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10266 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10267 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10269 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10270 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10271 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10272 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10273 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10274 {
10275 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10276 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10277 }
10278
10279 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10280 }
10281
10282 bool eScript::animate(int32_t index)
10283 {
10284 if(switch_hooked) return enemy::animate(index);
10285 if(fallclk||drownclk) return enemy::animate(index);
10286 if(fading)
10287 {
10288 if(++clk4 > 60)
10289 {
10290 clk4=0;
10291 superman=0;
10292 fading=0;
10293
10294 if(flags2&cmbflag_armos && z==0 && fakez==0)
10295 removearmos(x,y,ffcactivated);
10296
10297 clk2=0;
10298
10299 if(!canmove(down,(zfix)8,spw_none,false))
10300 {
10301 dir=0;
10302 y = y.getInt() & 0xF0;
10303 }
10304
10305 return Dead(index);
10306 }
10307 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10308 removearmos(x,y,ffcactivated);
10309 }
10310
10311 return enemy::animate(index);
10312 }
10313
10314 void eScript::draw(BITMAP *dest)
10315 {
10316 update_enemy_frame();
10317 enemy::draw(dest);
10318 }
10319
10320 int32_t eScript::takehit(weapon *w, weapon* realweap)
10321 {
10322 int32_t wpnId = w->id;
10323 int32_t wpnDir = w->dir;
10324
10325 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10326 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10327 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10328 {
10329 shield = false;
10330 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10331
10332 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10333 o_tile=s_tile;
10334 }
10335
10336 int32_t ret = enemy::takehit(w,realweap);
10337 return ret;
10338 }
10339
10340 void eScript::break_shield()
10341 {
10342 if(!shield)
10343 return;
10344
10345 flags&=~(inv_front | inv_back | inv_left | inv_right);
10346 shield=false;
10347
10348 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10349 o_tile=s_tile;
10350 }
10351
10352
10353 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10354 {
10355 clk4=0;
10356 hyofs = -32768; //No hitbox initially.
10357 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10358
10359 // Spawn type
10360 if(flags & guy_fadeflicker)
10361 {
10362 clk=0;
10363 superman = 1;
10364 fading=fade_flicker;
10365 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10366 dir=down;
10367
10368 if(!canmove(down,(zfix)8,spw_none,false))
10369 clk3=int32_t(13.0/step);
10370 }
10371 else if(flags & guy_fadeinstant)
10372 {
10373 clk=0;
10374 }
10375 SIZEflags = d->SIZEflags;
10376 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10377 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10378 // al_trace("Enemy txsz:%i\n", txsz);
10379 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10380 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10381 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10382 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10383 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10384 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10385 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10386 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10387 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10388 {
10389 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10390 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10391 }
10392
10393 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10394 }
10395
10396 bool eFriendly::animate(int32_t index)
10397 {
10398 if(switch_hooked) return enemy::animate(index);
10399 if(fallclk||drownclk) return enemy::animate(index);
10400 if(fading)
10401 {
10402 if(++clk4 > 60)
10403 {
10404 clk4=0;
10405 superman=0;
10406 fading=0;
10407
10408 if(flags2&cmbflag_armos && z==0 && fakez==0)
10409 removearmos(x,y,ffcactivated);
10410
10411 clk2=0;
10412
10413 if(!canmove(down,(zfix)8,spw_none,false))
10414 {
10415 dir=0;
10416 y = y.getInt() & 0xF0;
10417 }
10418
10419 return Dead(index);
10420 }
10421 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10422 removearmos(x,y,ffcactivated);
10423 }
10424
10425 return enemy::animate(index);
10426 }
10427
10428 void eFriendly::draw(BITMAP *dest)
10429 {
10430 update_enemy_frame();
10431 enemy::draw(dest);
10432 }
10433
10434 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
10435 {
10436 int32_t wpnId = w->id;
10437 int32_t wpnDir = w->dir;
10438
10439 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10440 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10441 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10442 {
10443 shield = false;
10444 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10445
10446 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10447 o_tile=s_tile;
10448 }
10449
10450 int32_t ret = enemy::takehit(w,realweap);
10451 return ret;
10452 }
10453
10454 void eFriendly::break_shield()
10455 {
10456 if(!shield)
10457 return;
10458
10459 flags&=~(inv_front | inv_back | inv_left | inv_right);
10460 shield=false;
10461
10462 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10463 o_tile=s_tile;
10464 }
10465
10466
10467 332509 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
10468 {
10469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332509 times.
332509 if (ffcactive)
10470 {
10471 removearmosffc(ffcactive-1);
10472 return;
10473 }
10474
2/2
✓ Branch 0 taken 331859 times.
✓ Branch 1 taken 650 times.
332509 if(did_armos)
10475 {
10476 331859 return;
10477 }
10478
10479 650 did_armos=true;
10480 650 ax&=0xF0;
10481 650 ay&=0xF0;
10482 650 int32_t cd = (ax>>4)+ay;
10483 650 int32_t f = MAPFLAG(ax,ay);
10484 650 int32_t f2 = MAPCOMBOFLAG(ax,ay);
10485
10486
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 110 times.
650 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
10487 {
10488 540 return;
10489 }
10490
10491 110 tmpscr->data[cd] = tmpscr->undercombo;
10492 110 tmpscr->cset[cd] = tmpscr->undercset;
10493 110 tmpscr->sflag[cd] = 0;
10494
10495
3/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 90 times.
110 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
10496 {
10497 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
10498 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
10499 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
10500 20 sfx(tmpscr->secretsfx);
10501 20 }
10502
10503
3/4
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 108 times.
110 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
10504 {
10505
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10506 {
10507 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10508 2 sfx(tmpscr->secretsfx);
10509 2 }
10510 2 }
10511
10512 110 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
10513 332509 }
10514
10515 void enemy::removearmosffc(int32_t pos)
10516 {
10517 if(did_armos)
10518 {
10519 return;
10520 }
10521
10522 did_armos=true;
10523 ffcdata& ffc = tmpscr->ffcs[pos];
10524 newcombo const& cmb = combobuf[ffc.getData()];
10525 int32_t f2 = cmb.flag;
10526
10527 if(cmb.type!=cARMOS)
10528 {
10529 return;
10530 }
10531
10532 ffc.setData(tmpscr->undercombo);
10533 ffc.cset = tmpscr->undercset;
10534
10535 if(f2 == mfARMOS_SECRET)
10536 {
10537 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
10538 ffc.cset = tmpscr->secretcset[sSTAIRS];
10539 sfx(tmpscr->secretsfx);
10540 }
10541
10542 if(f2 == mfARMOS_ITEM)
10543 {
10544 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10545 {
10546 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10547 sfx(tmpscr->secretsfx);
10548 }
10549 }
10550
10551 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
10552 }
10553
10554
10555 278 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10556 278 {
10557 139 fading=fade_flicker;
10558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10559 139 dir=12;
10560 139 movestatus=1;
10561
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 step=0;
10562 139 clk=0;
10563 139 clk4=0;
10564 139 SIZEflags = d->SIZEflags;
10565
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10566 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10567 // al_trace("Enemy txsz:%i\n", txsz);
10568
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10569
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10571
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10572
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10573
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10574 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10575
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10577 {
10578 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10579 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10580 }
10581
10582
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10583 139 }
10584
10585 50941 bool eGhini::animate(int32_t index)
10586 {
10587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50941 times.
50941 if(switch_hooked) return enemy::animate(index);
10588
2/4
✓ Branch 0 taken 50941 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 50941 times.
50941 if(fallclk||drownclk) return enemy::animate(index);
10589
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 50905 times.
50941 if(dying)
10590 36 return Dead(index);
10591
10592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50905 times.
50905 if(dmisc1)
10593 {
10594
2/2
✓ Branch 0 taken 42559 times.
✓ Branch 1 taken 8346 times.
50905 if(misc)
10595 {
10596
2/2
✓ Branch 0 taken 11685 times.
✓ Branch 1 taken 30874 times.
42559 if(clk4>160)
10597 30874 misc=2;
10598
10599
2/2
✓ Branch 0 taken 11685 times.
✓ Branch 1 taken 30874 times.
42559 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
10600 42559 removearmos(x,y,ffcactivated);
10601 42559 }
10602
2/2
✓ Branch 0 taken 8212 times.
✓ Branch 1 taken 134 times.
8346 else if(clk4>=60)
10603 {
10604 134 misc=1;
10605 134 clk3=32;
10606 134 fading=0;
10607
1/2
✓ Branch 0 taken 134 times.
✗ Branch 1 not taken.
134 if (ffcactivated > 0)
10608 {
10609 guygridffc[ffcactivated-1] = 0;
10610 removearmosffc(ffcactivated-1);
10611 }
10612 else
10613 {
10614 134 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
10615 134 removearmos(x,y);
10616 }
10617 134 }
10618 50905 }
10619
10620 50905 clk4++;
10621
10622 50905 return enemy::animate(index);
10623 50941 }
10624
10625 101940 void eGhini::draw(BITMAP *dest)
10626 {
10627 101940 update_enemy_frame();
10628 101940 enemy::draw(dest);
10629 101940 }
10630
10631 2 void eGhini::kickbucket()
10632 {
10633 2 hp=-1000; // don't call death_sfx()
10634 2 }
10635
10636
3/6
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2388 times.
✗ Branch 5 not taken.
7164 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10637 4776 {
10638
1/2
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
2388 old_y=y;
10639 2388 dir=down;
10640 2388 misc=1;
10641 2388 clk=-15;
10642
10643
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 20 times.
2388 if(!BSZ)
10644
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
10645
10646 // avoid divide by 0 errors
10647
1/2
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
2388 if(dmisc1 == 0)
10648 dmisc1 = 24;
10649
10650
1/2
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
2388 if(dmisc2 == 0)
10651 dmisc2 = 3;
10652
10653 //nets+760;
10654 2388 SIZEflags = d->SIZEflags;
10655
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2388 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10656 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10657 // al_trace("Enemy txsz:%i\n", txsz);
10658
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2388 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10659
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2388 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10660
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2388 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10661
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2388 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10662
1/2
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
2388 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10663
1/2
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
2388 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10664 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10665
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2388 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
2388 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10667 {
10668 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10669 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10670 }
10671
10672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2388 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2388 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10673 2388 }
10674
10675 784070 bool eTektite::animate(int32_t index)
10676 {
10677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 784070 times.
784070 if(switch_hooked) return enemy::animate(index);
10678
4/4
✓ Branch 0 taken 780002 times.
✓ Branch 1 taken 4068 times.
✓ Branch 2 taken 4068 times.
✓ Branch 3 taken 784070 times.
784070 if(fallclk||drownclk) return enemy::animate(index);
10679
2/2
✓ Branch 0 taken 17409 times.
✓ Branch 1 taken 766661 times.
784070 if(dying)
10680 17409 return Dead(index);
10681
10682
2/2
✓ Branch 0 taken 747180 times.
✓ Branch 1 taken 19481 times.
766661 if(clk==0)
10683 {
10684 19481 removearmos(x,y,ffcactivated);
10685 19481 }
10686
10687
2/2
✓ Branch 0 taken 433527 times.
✓ Branch 1 taken 333134 times.
766661 if(get_bit(quest_rules,qr_ENEMIESZAXIS))
10688 {
10689 333134 y=floor_y;
10690 333134 }
10691
10692
9/10
✓ Branch 0 taken 691590 times.
✓ Branch 1 taken 75071 times.
✓ Branch 2 taken 686670 times.
✓ Branch 3 taken 4920 times.
✓ Branch 4 taken 686670 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10838 times.
✓ Branch 7 taken 675832 times.
✓ Branch 8 taken 5306 times.
✓ Branch 9 taken 9640 times.
766661 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
10693 {
10694
4/4
✓ Branch 0 taken 8176 times.
✓ Branch 1 taken 274734 times.
✓ Branch 2 taken 175996 times.
✓ Branch 3 taken 226566 times.
685472 switch(misc)
10695 {
10696 case 0: // normal
10697
2/2
✓ Branch 0 taken 269013 times.
✓ Branch 1 taken 5721 times.
274734 if(!(zc_oldrand()%dmisc1))
10698 {
10699 5721 misc=1;
10700 5721 clk2=32;
10701 5721 }
10702
10703 274734 break;
10704
10705 case 1: // waiting to pounce
10706
2/2
✓ Branch 0 taken 166722 times.
✓ Branch 1 taken 9274 times.
175996 if(--clk2<=0)
10707 {
10708 9274 int32_t r=zc_oldrand();
10709 9274 misc=2;
10710 9274 step=0-(zslongToFix(dstep*100)); // initial speed
10711 9274 clk3=(r&1)+2; // left or right
10712 9274 clk2start=clk2=(r&31)+10; // flight time
10713
10714
2/2
✓ Branch 0 taken 8102 times.
✓ Branch 1 taken 1172 times.
9274 if(y<32) clk2+=2; // make them come down from top of screen
10715
10716
2/2
✓ Branch 0 taken 7180 times.
✓ Branch 1 taken 2094 times.
9274 if(y>112) clk2-=2; // make them go back up
10717
10718 9274 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
10719 9274 }
10720
10721 175996 break;
10722
10723 case 2: // in flight
10724 226566 move(step);
10725
10726
2/2
✓ Branch 0 taken 109038 times.
✓ Branch 1 taken 117528 times.
226566 if(step>0) //going down
10727 {
10728
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 108882 times.
109038 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
10729 {
10730 156 step=0-step;
10731 156 }
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108882 times.
108882 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
10733 {
10734 step=0-step;
10735 }
10736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108882 times.
108882 else if(ispitfall(x+8,y+16))
10737 {
10738 step=0-step;
10739 }
10740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108882 times.
108882 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
10741 {
10742 step=0-step;
10743 }
10744
1/2
✓ Branch 0 taken 108882 times.
✗ Branch 1 not taken.
108882 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
10745 {
10746 step=0-step;
10747 }
10748 109038 }
10749
2/2
✓ Branch 0 taken 7567 times.
✓ Branch 1 taken 109961 times.
117528 else if(step<0)
10750 {
10751
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 109742 times.
109961 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
10752 {
10753 219 step=0-step;
10754 219 }
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109742 times.
109742 else if(COMBOTYPE(x+8,y)==cNOENEMY)
10756 {
10757 step=0-step;
10758 }
10759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109742 times.
109742 else if(ispitfall(x+8,y))
10760 {
10761 step=0-step;
10762 }
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109742 times.
109742 else if(MAPFLAG(x+8,y)==mfNOENEMY)
10764 {
10765 step=0-step;
10766 }
10767
1/2
✓ Branch 0 taken 109742 times.
✗ Branch 1 not taken.
109742 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
10768 {
10769 step=0-step;
10770 }
10771 109961 }
10772
10773
2/2
✓ Branch 0 taken 112812 times.
✓ Branch 1 taken 113754 times.
226566 if(clk3==left)
10774 {
10775
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 112711 times.
112812 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
10776 {
10777 101 clk3^=1;
10778 101 }
10779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112711 times.
112711 else if(COMBOTYPE(x,y+8)==cNOENEMY)
10780 {
10781 clk3^=1;
10782 }
10783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112711 times.
112711 else if(ispitfall(x,y+8))
10784 {
10785 clk3^=1;
10786 }
10787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 112711 times.
112711 else if(MAPFLAG(x,y+8)==mfNOENEMY)
10788 {
10789 clk3^=1;
10790 }
10791
1/2
✓ Branch 0 taken 112711 times.
✗ Branch 1 not taken.
112711 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
10792 {
10793 clk3^=1;
10794 }
10795 112812 }
10796 else
10797 {
10798
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 113663 times.
113754 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
10799 {
10800 91 clk3^=1;
10801 91 }
10802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113663 times.
113663 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
10803 {
10804 clk3^=1;
10805 }
10806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113663 times.
113663 else if(ispitfall(x+16,y+8))
10807 {
10808 clk3^=1;
10809 }
10810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113663 times.
113663 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
10811 {
10812 clk3^=1;
10813 }
10814
1/2
✓ Branch 0 taken 113663 times.
✗ Branch 1 not taken.
113663 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
10815 {
10816 clk3^=1;
10817 }
10818 }
10819
10820 226566 --c;
10821
10822
4/4
✓ Branch 0 taken 68355 times.
✓ Branch 1 taken 158211 times.
✓ Branch 2 taken 148988 times.
✓ Branch 3 taken 77578 times.
226566 if(c<0 && step<zslongToFix(dstep*100))
10823 {
10824 77578 step+=zslongToFix(dmisc3*100);
10825 77578 }
10826
10827 226566 int32_t nb=get_bit(quest_rules,qr_NOBORDER) ? 16 : 0;
10828
10829
2/2
✓ Branch 0 taken 226320 times.
✓ Branch 1 taken 246 times.
226566 if(x<=16-nb) clk3=right;
10830
10831
2/2
✓ Branch 0 taken 226106 times.
✓ Branch 1 taken 460 times.
226566 if(x>=224+nb) clk3=left;
10832
10833 226566 x += (clk3==left) ? -1 : 1;
10834
10835
4/4
✓ Branch 0 taken 12808 times.
✓ Branch 1 taken 213758 times.
✓ Branch 2 taken 4095 times.
✓ Branch 3 taken 209663 times.
226566 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
10836 {
10837
4/4
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 8188 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
16903 if(y>=144+nb && get_bit(quest_rules,qr_ENEMIESZAXIS))
10838 {
10839 177 step=0-step;
10840 177 y--;
10841 177 }
10842
2/2
✓ Branch 0 taken 6697 times.
✓ Branch 1 taken 1853 times.
8550 else if(zc_oldrand()%dmisc2) //land and wait
10843 {
10844 6697 clk=misc=0;
10845 6697 } //land and jump again
10846 else
10847 {
10848 1853 misc=1;
10849 1853 clk2=0;
10850 }
10851 8727 }
10852
10853 218390 break;
10854 } // switch
10855 677296 }
10856
10857
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 429459 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
762593 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10858 {
10859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
10860 {
10861 int32_t tempy = floor_y;
10862 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
10863 floor_y = y;
10864 y=tempy-fakez;
10865 old_y = y;
10866 }
10867 else
10868 {
10869 106683 int32_t tempy = floor_y;
10870
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 2353 times.
✓ Branch 3 taken 104330 times.
✓ Branch 4 taken 52359 times.
✓ Branch 5 taken 51971 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
10871 106683 floor_y = y;
10872 106683 y=tempy-z;
10873 106683 old_y = y;
10874 }
10875 106683 }
10876
10877
4/4
✓ Branch 0 taken 4920 times.
✓ Branch 1 taken 757673 times.
✓ Branch 2 taken 978 times.
✓ Branch 3 taken 3942 times.
762593 if(stunclk && (clk&31)==1)
10878 3942 clk=0;
10879
10880 762593 return enemy::animate(index);
10881 780002 }
10882
10883 205194 void eTektite::drawshadow(BITMAP *dest,bool translucent)
10884 {
10885
5/6
✓ Branch 0 taken 35638 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 35638 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✓ Branch 5 taken 24334 times.
205194 if(z<1 && fakez<1 && get_bit(quest_rules,qr_ENEMIESZAXIS))
10886 24334 return;
10887
10888 180860 int32_t tempy=yofs;
10889 180860 int32_t fdiv = frate/4;
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180860 times.
180860 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180860 times.
180860 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
10892 180860 efrate:((clk>=(frate>>1))?1:0);
10893 180860 flip = 0;
10894 180860 shadowtile = wpnsbuf[spr_shadow].tile;
10895
10896
1/2
✓ Branch 0 taken 180860 times.
✗ Branch 1 not taken.
180860 if(get_bit(quest_rules,qr_NEWENEMYTILES))
10897 {
10898
2/2
✓ Branch 0 taken 68075 times.
✓ Branch 1 taken 112785 times.
180860 if(misc==0)
10899 {
10900 68075 shadowtile+=f2;
10901 68075 }
10902
2/2
✓ Branch 0 taken 50479 times.
✓ Branch 1 taken 62306 times.
112785 else if(misc!=1)
10903 62306 shadowtile+=2;
10904 180860 }
10905 else
10906 {
10907 if(misc==0)
10908 {
10909 shadowtile += f2 ? 1 : 0;
10910 }
10911 else if(misc!=1)
10912 {
10913 ++shadowtile;
10914 }
10915 }
10916
10917 180860 yofs+=8;
10918
10919
4/4
✓ Branch 0 taken 11304 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 5927 times.
✓ Branch 3 taken 5377 times.
180860 if(!get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10920 {
10921
6/6
✓ Branch 0 taken 2662 times.
✓ Branch 1 taken 2715 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 5057 times.
✓ Branch 4 taken 2556 times.
✓ Branch 5 taken 2501 times.
5377 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
10922 5377 }
10923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180860 times.
180860 if(!shadow_overpit(this))
10924 180860 enemy::drawshadow(dest,translucent);
10925 180860 yofs=tempy;
10926 205194 }
10927
10928 1375168 void eTektite::draw(BITMAP *dest)
10929 {
10930 1375168 update_enemy_frame();
10931 1375168 enemy::draw(dest);
10932 1375168 }
10933
10934 766 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10935 766 {
10936
2/4
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 383 times.
✗ Branch 3 not taken.
383 step=zslongToFix(guysbuf[id&0xFFF].step*100);
10937 383 superman=1;
10938 383 dir=8;
10939 383 hxofs=1000;
10940 383 mainguy=false;
10941 383 count_enemy=false;
10942
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
383 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10943 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10944 // al_trace("Enemy txsz:%i\n", txsz);
10945
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
383 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
10946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
10947
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
10948
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
383 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
10949
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
10950
1/2
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
383 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
10951 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10952
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
383 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
10953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
383 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10954 {
10955 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
10956 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10957 }
10958
10959
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 383 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
383 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
10960 383 }
10961
10962 217928 bool eItemFairy::animate(int32_t index)
10963 {
10964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217928 times.
217928 if(switch_hooked) return enemy::animate(index);
10965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 217928 times.
217928 if(dying)
10966 return Dead(index);
10967
10968 //if(clk>32)
10969 217928 misc=1;
10970 217928 bool w=watch;
10971 217928 watch=false;
10972 217928 variable_walk_8(misc?3:0,0,8,spw_floater);
10973 217928 watch=w;
10974
10975
2/2
✓ Branch 0 taken 1052 times.
✓ Branch 1 taken 216876 times.
217928 if(clk==0)
10976 {
10977 1052 removearmos(x,y,ffcactivated);
10978 1052 }
10979
10980 217928 return enemy::animate(index);
10981 217928 }
10982
10983 437012 void eItemFairy::draw(BITMAP *dest)
10984 {
10985 //these are here to bypass compiler warnings about unused arguments
10986 437012 dest=dest;
10987 437012 }
10988
10989 1730 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10990 1730 {
10991 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
10992
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✓ Branch 2 taken 865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 865 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 865 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 865 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 865 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 865 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 865 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 865 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 865 times.
✗ Branch 19 not taken.
865 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
10993 865 dir=8;
10994 865 movestatus=1;
10995 865 clk=0;
10996
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 step=0;
10997 //nets+720;
10998 865 SIZEflags = d->SIZEflags;
10999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
865 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11000 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11001 // al_trace("Enemy txsz:%i\n", txsz);
11002
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
865 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
865 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
865 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
865 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11006
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11007
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11008 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11009
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
865 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11011 {
11012 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11013 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11014 }
11015
11016
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
865 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11017 865 }
11018
11019 262180 bool ePeahat::animate(int32_t index)
11020 {
11021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 262180 times.
262180 if(switch_hooked) return enemy::animate(index);
11022
2/4
✓ Branch 0 taken 262180 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 262180 times.
262180 if(fallclk||drownclk) return enemy::animate(index);
11023
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 262102 times.
262180 if(slide())
11024 {
11025 78 return false;
11026 }
11027
11028
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 261616 times.
262102 if(dying)
11029 486 return Dead(index);
11030
11031
2/2
✓ Branch 0 taken 260042 times.
✓ Branch 1 taken 1574 times.
261616 if(clk==0)
11032 {
11033 1574 removearmos(x,y,ffcactivated);
11034 1574 }
11035
11036
4/4
✓ Branch 0 taken 258836 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 123988 times.
✓ Branch 3 taken 134848 times.
261616 if(stunclk==0 && clk>96)
11037 134848 misc=1;
11038
11039
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 259214 times.
261616 if(!watch)
11040
2/2
✓ Branch 0 taken 174832 times.
✓ Branch 1 taken 84382 times.
259214 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
11041
11042
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 161598 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
261616 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11043 {
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11045 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
11046 100018 }
11047
11048
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 259214 times.
✓ Branch 2 taken 1634 times.
✓ Branch 3 taken 768 times.
261616 if(watch && get_bit(quest_rules,qr_PEAHATCLOCKVULN))
11049 1634 superman=0;
11050 else
11051
2/2
✓ Branch 0 taken 253338 times.
✓ Branch 1 taken 6644 times.
259982 superman=(movestatus && !get_bit(quest_rules,qr_ENEMIESZAXIS)) ? 1 : 0;
11052 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
11053
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 65597 times.
261616 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
11054 {
11055
2/2
✓ Branch 0 taken 2777 times.
✓ Branch 1 taken 193242 times.
196019 if ( stunclk ) --stunclk;
11056 196019 }
11057 65597 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
11058 //Pretty sure this was always an error. -Z ( 14FEB2019 )
11059
11060
11061
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 261394 times.
261616 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
11062
11063 261616 return enemy::animate(index);
11064 262180 }
11065
11066 88089 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
11067 {
11068 88089 int32_t tempy=yofs;
11069 88089 flip = 0;
11070 88089 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11071
11072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
11073 {
11074 yofs+=8;
11075 yofs+=int32_t(step/zslongToFix(dstep*10));
11076 }
11077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!shadow_overpit(this))
11078 88089 enemy::drawshadow(dest,translucent);
11079 88089 yofs=tempy;
11080 88089 }
11081
11082 618206 void ePeahat::draw(BITMAP *dest)
11083 {
11084 618206 update_enemy_frame();
11085 618206 enemy::draw(dest);
11086 618206 }
11087
11088 930 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
11089 {
11090 930 int32_t wpnId = w->id;
11091 930 int32_t enemyHitWeapon = w->parentitem;
11092
11093
3/6
✓ Branch 0 taken 930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 930 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 930 times.
930 if(dying || clk<0 || hclk>0)
11094 return 0;
11095
11096
4/4
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 102 times.
1062 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
11097 // fire boomerang, for nailing peahats
11098
4/6
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 604 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
736 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
11099 706 return 0;
11100
11101 // Time for a kludge...
11102 224 int32_t s = superman;
11103 224 superman = 0;
11104 224 int32_t ret = enemy::takehit(w,realweap);
11105 224 superman = s;
11106
11107 // Anyway...
11108
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 141 times.
224 if(stunclk == 160)
11109 {
11110 141 clk2=0;
11111 141 movestatus=0;
11112 141 misc=0;
11113 141 clk=0;
11114 141 step=0;
11115 141 }
11116
11117 224 return ret;
11118 930 }
11119
11120 // auomatically kill off enemy (for rooms with ringleaders)
11121 void ePeahat::kickbucket()
11122 {
11123 hp=-1000; // don't call death_sfx()
11124 }
11125
11126 3388 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11127 3388 {
11128 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
11129
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
11130 {
11131 941 misc=-1; //Line of Sight leevers
11132 941 clk-=16;
11133 941 }
11134 1694 clk3 = 0;
11135 //nets+1460;
11136
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 temprule=(get_bit(quest_rules,qr_NEWENEMYTILES)) != 0;
11137 1694 submerged = false;
11138 1694 SIZEflags = d->SIZEflags;
11139
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11140 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11141 // al_trace("Enemy txsz:%i\n", txsz);
11142
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11143
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11144
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11146
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11147
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11148 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11151 {
11152 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11153 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11154 }
11155
11156
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11157 1694 }
11158
11159 bool eLeever::isSubmerged() const
11160 {
11161 Z_scripterrlog("misc is: %d\n", misc);
11162 return misc <= 0;
11163
11164 }
11165
11166 499943 bool eLeever::animate(int32_t index)
11167 {
11168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
11169
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
11170 {
11171 return enemy::animate(index);
11172 }
11173
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
11174 16506 return Dead(index);
11175
11176
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
11177 {
11178 20340 removearmos(x,y,ffcactivated);
11179 20340 }
11180
11181
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
11182 {
11183 // switch(d->misc1)
11184
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
11185 {
11186 case 0: //line of sight
11187 case 2:
11188
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
11189 {
11190 case -1: //submerged
11191 {
11192
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
11193
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
11194 {
11195 7582 break;
11196 }
11197
11198 59968 int32_t active=0;
11199
11200
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
11201 {
11202
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
11203 {
11204 118794 ++active;
11205 118794 }
11206 424896 }
11207
11208
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
11209 {
11210 821 misc=0; //activate this one
11211 821 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
11212 821 }
11213 }
11214 59968 break;
11215
11216 case 0:
11217 {
11218
11219
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11220 {
11221 misc=1;
11222 clk2=0;
11223 }
11224
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
11225 {
11226 36 misc = -1;
11227 36 break;
11228 }
11229 17100 int32_t s=0;
11230
11231
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
11232 {
11233
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
11234 {
11235 2162 ++s;
11236 2162 }
11237 112208 }
11238
11239
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
11240 {
11241 2162 break;
11242 }
11243
11244 14938 int32_t d2=zc_oldrand()&1;
11245
11246
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
11247 {
11248 9602 d2+=2;
11249 9602 }
11250
11251
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
11252 {
11253 943 misc=1;
11254 943 clk2=0;
11255 943 clk=0;
11256 943 }
11257 }
11258 14938 break;
11259
11260 case 1:
11261
11262
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
11263
11264 15898 break;
11265
11266 case 2:
11267
11268
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
11269
11270 7088 break;
11271
11272 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
11273 case 3:
11274
11275
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
11276
11277
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
11278
11279
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
11280 39402 else move(zslongToFix(dstep*100));
11281
11282 39613 break;
11283
11284 case 4:
11285
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
11286
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
11287 {
11288 197 misc=5;
11289 197 clk=8;
11290 197 }
11291
11292 1832 break;
11293
11294 case 5:
11295
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
11296
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
11297
11298 2915 break;
11299 } // switch(misc)
11300
11301 156396 break;
11302
11303 default: //random
11304 // step=d->misc3/100.0;
11305
11306 234267 step=zslongToFix(dmisc3*100);
11307
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
11308 else if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11309 {
11310 if (clk2 < 48) clk2+=2;
11311 if (clk2 >= 300) clk2-=2;
11312 }
11313
11314
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
11315
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
11316
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
11317 {
11318 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
11319 {
11320 fix_coords();
11321 }*/
11322 140831 misc=3;
11323 140831 step = zslongToFix(dstep*100);
11324 140831 }
11325
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
11326
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
11327
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
11328 {
11329 23490 misc=0;
11330 23490 step=0;
11331 23490 }
11332 169 else clk2=0;
11333
11334
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
11335
11336 // variable_walk(d->rate, d->homing, 0);
11337 234267 variable_walk(rate, homing, 0);
11338 234267 } // switch(dmisc1)
11339 390663 }
11340
11341 483437 hxofs=(misc>=2)?0:1000;
11342 483437 return enemy::animate(index);
11343 499943 }
11344
11345 29233 bool eLeever::canplace(int32_t d2)
11346 {
11347 29233 int32_t nx=HeroX();
11348 29233 int32_t ny=HeroY();
11349
11350
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
11351 18829 else nx&=0xF0;
11352
11353
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
11354 {
11355 // case up: ny-=((d->misc1==0)?32:48); break;
11356 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
11357 // case left: nx-=((d->misc1==0)?32:48); break;
11358 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
11359 case up:
11360
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
11361 5173 break;
11362
11363 case down:
11364
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
11365
11366
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
11367
11368 5231 break;
11369
11370 case left:
11371
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
11372 9395 break;
11373
11374 case right:
11375
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
11376
11377
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
11378
11379 9434 break;
11380 }
11381
11382
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
11383 23696 return false;
11384
11385
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
11386
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
11387 4594 return false;
11388
11389 943 x=nx;
11390 943 y=ny;
11391 943 dir=d2^1;
11392 943 return true;
11393 29233 }
11394
11395 500779 void eLeever::draw(BITMAP *dest)
11396 {
11397 // cs=d->cset;
11398 500779 cs=dcset;
11399 500779 update_enemy_frame();
11400
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
11401 {
11402
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
11403 {
11404 case -1:
11405 case 0:
11406 199634 return;
11407 }
11408 301145 }
11409
11410 301145 enemy::draw(dest);
11411 500779 }
11412
11413 938 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11414 938 {
11415 //zprint2("eWallM::eWallM\n");
11416 469 hashero=false;
11417 //nets+1000;
11418 469 SIZEflags = d->SIZEflags;
11419
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11420 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11421 // al_trace("Enemy txsz:%i\n", txsz);
11422
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
469 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11426
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11427
1/2
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
469 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11428 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11429
1/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
469 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11431 {
11432 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11433 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11434 }
11435
11436
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
469 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11437 469 }
11438
11439 296039 bool eWallM::animate(int32_t index)
11440 {
11441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296039 times.
296039 if(switch_hooked) return enemy::animate(index);
11442
2/4
✓ Branch 0 taken 296039 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 296039 times.
296039 if(fallclk||drownclk)
11443 {
11444 return enemy::animate(index);
11445 }
11446
2/2
✓ Branch 0 taken 5862 times.
✓ Branch 1 taken 290177 times.
296039 if(dying)
11447 5862 return Dead(index);
11448
11449
2/2
✓ Branch 0 taken 271686 times.
✓ Branch 1 taken 18491 times.
290177 if(clk==0)
11450 {
11451 18491 removearmos(x,y,ffcactivated);
11452 18491 }
11453
11454 290177 hxofs=1000;
11455
2/2
✓ Branch 0 taken 74303 times.
✓ Branch 1 taken 215874 times.
290177 if(misc==0) //inside wall, ready to spawn?
11456 {
11457 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
11458 //zprint2("frame is: %d\n",frame);
11459 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
11460
4/4
✓ Branch 0 taken 143051 times.
✓ Branch 1 taken 72823 times.
✓ Branch 2 taken 8214 times.
✓ Branch 3 taken 134837 times.
215874 if(frame-wallm_load_clk>80 && clk>=0)
11461 {
11462 //zprint2("getting wall\n");
11463 134837 int32_t wall=hero_on_wall();
11464 //zprint2("Wallmaster wall is %d\n",wall);
11465 134837 int32_t wallm_cnt=0;
11466
11467
2/2
✓ Branch 0 taken 1046303 times.
✓ Branch 1 taken 134837 times.
1181140 for(int32_t i=0; i<guys.Count(); i++)
11468
2/2
✓ Branch 0 taken 399790 times.
✓ Branch 1 taken 646513 times.
1692816 if(((enemy*)guys.spr(i))->family==eeWALLM)
11469 {
11470 646513 int32_t m=((enemy*)guys.spr(i))->misc;
11471
11472
4/4
✓ Branch 0 taken 29106 times.
✓ Branch 1 taken 617407 times.
✓ Branch 2 taken 17904 times.
✓ Branch 3 taken 11202 times.
646513 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
11473 {
11474 11202 ++wallm_cnt;
11475 11202 }
11476 646513 }
11477
11478
2/2
✓ Branch 0 taken 134373 times.
✓ Branch 1 taken 464 times.
134837 if(wall>0)
11479 {
11480 464 --wall;
11481 464 misc=1; //emerging from the wall?
11482 //zprint2("Wallmaster is emerging\n");
11483 464 clk2=0;
11484 464 clk3=wall^1;
11485 464 wallm_load_clk=frame;
11486
11487
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 188 times.
464 if(wall<=down)
11488 {
11489
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 228 times.
276 if(HeroDir()==left)
11490 48 dir=right;
11491 else
11492 228 dir=left;
11493 276 }
11494 else
11495 {
11496
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 150 times.
188 if(HeroDir()==up)
11497 38 dir=down;
11498 else
11499 150 dir=up;
11500 }
11501
11502
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 130 times.
✓ Branch 3 taken 128 times.
✓ Branch 4 taken 60 times.
464 switch(wall)
11503 {
11504 case up:
11505 146 y=0;
11506 146 break;
11507
11508 case down:
11509 130 y=160;
11510 130 break;
11511
11512 case left:
11513 128 x=0;
11514 128 break;
11515
11516 case right:
11517 60 x=240;
11518 60 break;
11519 }
11520
11521 //zprint2("Wallmaster (p1) x is %d\n",x);
11522 //zprint2("Wallmaster (p1) y is %d\n",y);
11523
11524
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 228 times.
✓ Branch 4 taken 48 times.
464 switch(dir)
11525 {
11526 case up:
11527 150 y=(HeroY()+48-(wallm_cnt&1)*12);
11528 150 flip=wall&1;
11529 150 break;
11530
11531 case down:
11532 38 y=(HeroY()-48+(wallm_cnt&1)*12);
11533 38 flip=((wall&1)^1)+2;
11534 38 break;
11535
11536 case left:
11537 228 x=(HeroX()+48-(wallm_cnt&1)*12);
11538 228 flip=(wall==up?2:0)+1;
11539 228 break;
11540
11541 case right:
11542 48 x=(HeroX()-48+(wallm_cnt&1)*12);
11543 48 flip=(wall==up?2:0);
11544 48 break;
11545 }
11546
11547 //zprint2("Wallmaster (p2) x is %d\n",x);
11548 //zprint2("Wallmaster (p2) y is %d\n",y);
11549 464 }
11550 134837 }
11551 215874 }
11552 else
11553 74303 wallm_crawl();
11554
11555 290177 return enemy::animate(index);
11556 296039 }
11557
11558 74303 void eWallM::wallm_crawl()
11559 {
11560 74303 bool w=watch;
11561 74303 hxofs=0;
11562
11563
2/2
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 73827 times.
74303 if(slide())
11564 {
11565 476 return;
11566 }
11567
11568 // if(dying || watch || (!hashero && stunclk))
11569
6/8
✓ Branch 0 taken 73827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 73538 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 59860 times.
✓ Branch 5 taken 13678 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59860 times.
73827 if(dying || (!hashero && ( stunclk || frozenclock )))
11570 {
11571 13678 return;
11572 }
11573
11574 60149 watch=false;
11575 60149 ++clk2;
11576 // Misc1: slightly different movement
11577 //zprint2("wallmaster crawl\n");
11578 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
11579 60149 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
11580
11581 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
11582 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
11583 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
11584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60149 times.
60149 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
11585 //zprint2("wallmaster crawl misc is: %d\n", misc);
11586
5/6
✓ Branch 0 taken 5628 times.
✓ Branch 1 taken 54521 times.
✓ Branch 2 taken 4388 times.
✓ Branch 3 taken 1240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4388 times.
60149 if(w&&misc>=3&&misc<=5)
11587 {
11588 4388 --clk2;
11589 4388 }
11590
11591
4/4
✓ Branch 0 taken 25651 times.
✓ Branch 1 taken 27926 times.
✓ Branch 2 taken 6468 times.
✓ Branch 3 taken 104 times.
60149 switch(misc)
11592 {
11593 case 1:
11594 case 2:
11595 27926 zc_swap(dir,clk3);
11596 27926 move(step);
11597 27926 zc_swap(dir,clk3);
11598 27926 break;
11599
11600 case 3:
11601 case 4:
11602 case 5:
11603
2/2
✓ Branch 0 taken 4388 times.
✓ Branch 1 taken 21263 times.
25651 if(w)
11604 {
11605 4388 watch=w;
11606 4388 return;
11607 }
11608
11609 21263 move(step);
11610 21263 break;
11611
11612 case 6:
11613 case 7:
11614 6468 zc_swap(dir,clk3);
11615 6468 dir^=1;
11616 6468 move(step);
11617 6468 dir^=1;
11618 6468 zc_swap(dir,clk3);
11619 6468 break;
11620
11621 default:
11622 104 misc=0;
11623 104 break;
11624 }
11625
11626 55761 watch=w;
11627 74303 }
11628
11629 3 void eWallM::grabhero()
11630 {
11631 3 hashero=true;
11632 3 superman=1;
11633 3 }
11634
11635 296315 void eWallM::draw(BITMAP *dest)
11636 {
11637 296315 dummy_bool[1]=hashero;
11638 296315 update_enemy_frame();
11639
11640
4/6
✓ Branch 0 taken 215864 times.
✓ Branch 1 taken 80451 times.
✓ Branch 2 taken 215864 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 215864 times.
296315 if(misc>0 || fallclk||drownclk)
11641 {
11642 80451 masked_draw(dest,16,playing_field_offset+16,224,144);
11643 80451 }
11644
11645 // enemy::draw(dest);
11646 // tile = clk&8 ? 128:129;
11647 296315 }
11648
11649 bool eWallM::isSubmerged() const
11650 {
11651 return ( !misc );
11652 }
11653
11654 1406 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11655 1406 {
11656
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 ox=x; //original x
11657
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 oy=y; //original y
11658
3/4
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 637 times.
703 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11659 {
11660
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11661 66 }
11662
11663 703 mainguy=false;
11664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
703 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11665 //nets+420;
11666 703 dummy_int[1]=0;
11667 703 SIZEflags = d->SIZEflags;
11668
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
703 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11669 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11670 // al_trace("Enemy txsz:%i\n", txsz);
11671
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
703 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11672
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
703 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
703 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
703 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11675
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11676
1/2
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
703 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11677 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11678
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
703 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
703 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11680 {
11681 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11682 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11683 }
11684
11685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 703 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
703 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11686 703 }
11687
11688 497627 bool eTrap::animate(int32_t index)
11689 {
11690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 497627 times.
497627 if(switch_hooked) return enemy::animate(index);
11691
2/4
✓ Branch 0 taken 497627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 497627 times.
497627 if(fallclk||drownclk) return enemy::animate(index);
11692
2/2
✓ Branch 0 taken 487789 times.
✓ Branch 1 taken 9838 times.
497627 if(clk<0)
11693 9838 return enemy::animate(index);
11694
11695
2/2
✓ Branch 0 taken 456955 times.
✓ Branch 1 taken 30834 times.
487789 if(clk==0)
11696 {
11697 30834 removearmos(x,y,ffcactivated);
11698 30834 }
11699
11700
2/2
✓ Branch 0 taken 128229 times.
✓ Branch 1 taken 359560 times.
487789 if(misc==0) // waiting
11701 {
11702 359560 ox = x;
11703 359560 oy = y;
11704 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11705 359560 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11706
11707
4/4
✓ Branch 0 taken 117876 times.
✓ Branch 1 taken 241684 times.
✓ Branch 2 taken 70558 times.
✓ Branch 3 taken 47318 times.
359560 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
11708 {
11709 47318 dir=down;
11710 47318 }
11711
4/4
✓ Branch 0 taken 210906 times.
✓ Branch 1 taken 101336 times.
✓ Branch 2 taken 70558 times.
✓ Branch 3 taken 140348 times.
312242 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
11712 {
11713 140348 dir=right;
11714 140348 }
11715
4/4
✓ Branch 0 taken 107679 times.
✓ Branch 1 taken 64215 times.
✓ Branch 2 taken 70558 times.
✓ Branch 3 taken 37121 times.
171894 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
11716 {
11717 37121 dir=up;
11718 37121 }
11719 else
11720 {
11721 134773 dir=left;
11722 }
11723
11724 359560 int32_t d2=lined_up(15,true);
11725
11726
4/4
✓ Branch 0 taken 123433 times.
✓ Branch 1 taken 236127 times.
✓ Branch 2 taken 668121 times.
✓ Branch 3 taken 308561 times.
586833 if(((d2<left || d2 > right) && (dmisc1==1)) ||
11727
2/2
✓ Branch 0 taken 118589 times.
✓ Branch 1 taken 189972 times.
308561 ((d2>down) && (dmisc1==2)) ||
11728
2/2
✓ Branch 0 taken 111768 times.
✓ Branch 1 taken 78204 times.
189972 ((d2>right) && (!dmisc1)) ||
11729
2/2
✓ Branch 0 taken 227273 times.
✓ Branch 1 taken 48451 times.
189972 ((d2<l_up) && (dmisc1==4)) ||
11730
3/4
✓ Branch 0 taken 227273 times.
✓ Branch 1 taken 178822 times.
✓ Branch 2 taken 227273 times.
✗ Branch 3 not taken.
48451 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
11731
3/4
✓ Branch 0 taken 227273 times.
✓ Branch 1 taken 48451 times.
✓ Branch 2 taken 227273 times.
✗ Branch 3 not taken.
178822 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
11732 {
11733 1468529 d2=-1;
11734 1468529 }
11735
11736
4/4
✓ Branch 0 taken 9596 times.
✓ Branch 1 taken 171142 times.
✓ Branch 2 taken 8613 times.
✓ Branch 3 taken 983 times.
180738 if(d2!=-1 && trapmove(d2))
11737 {
11738 983 dir=d2;
11739 983 misc=1;
11740 983 clk2=(dir==down)?3:0;
11741 983 }
11742 180738 }
11743
11744
2/2
✓ Branch 0 taken 273905 times.
✓ Branch 1 taken 35062 times.
308967 if(misc==1) // charging
11745 {
11746 35062 clk2=(clk2+1)&3;
11747 35062 step=(clk2==3)?1:2;
11748
11749
4/4
✓ Branch 0 taken 35012 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 34152 times.
35062 if(!trapmove(dir) || clip())
11750 {
11751 910 misc=2;
11752
11753
1/2
✓ Branch 0 taken 910 times.
✗ Branch 1 not taken.
910 if(dir<l_up)
11754 {
11755 910 dir=dir^1;
11756 910 }
11757 else
11758 {
11759 dir=dir^3;
11760 }
11761 910 }
11762 else
11763 {
11764 34152 sprite::move(step);
11765 }
11766 35062 }
11767
11768
2/2
✓ Branch 0 taken 213907 times.
✓ Branch 1 taken 95060 times.
308967 if(misc==2) // retreating
11769 {
11770 95060 step=(++clk2&1)?1:0;
11771
11772
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 12080 times.
✓ Branch 2 taken 36053 times.
✓ Branch 3 taken 11271 times.
✓ Branch 4 taken 35656 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
95060 switch(dir)
11773 {
11774 case up:
11775
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 11973 times.
12080 if(int32_t(y)<=oy) goto trap_rest;
11776 11973 else sprite::move(step);
11777
11778 11973 break;
11779
11780 case left:
11781
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 35848 times.
36053 if(int32_t(x)<=ox) goto trap_rest;
11782 35848 else sprite::move(step);
11783
11784 35848 break;
11785
11786 case down:
11787
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 11163 times.
11271 if(int32_t(y)>=oy) goto trap_rest;
11788 11163 else sprite::move(step);
11789
11790 11163 break;
11791
11792 case right:
11793
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 35440 times.
35656 if(int32_t(x)>=ox) goto trap_rest;
11794 35440 else sprite::move(step);
11795
11796 35440 break;
11797
11798 case l_up:
11799 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
11800 else sprite::move(step);
11801
11802 break;
11803
11804 case r_up:
11805 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
11806 else sprite::move(step);
11807
11808 break;
11809
11810 case l_down:
11811 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
11812 else sprite::move(step);
11813
11814 break;
11815
11816 case r_down:
11817 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
11818 else sprite::move(step);
11819
11820 break;
11821 trap_rest:
11822 {
11823 636 x=ox;
11824 636 y=oy;
11825 636 misc=0;
11826 }
11827 636 }
11828 95060 }
11829
11830 308967 return enemy::animate(index);
11831 318805 }
11832
11833 44658 bool eTrap::trapmove(int32_t ndir)
11834 {
11835
2/2
✓ Branch 0 taken 30391 times.
✓ Branch 1 taken 14267 times.
44658 if(get_bit(quest_rules,qr_MEANTRAPS))
11836 {
11837
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 29051 times.
30391 if(tmpscr->flags2&fFLOATTRAPS)
11838 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
11839
11840 29051 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
11841 }
11842
11843
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
11844 2766 return false;
11845
11846
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
11847 return false;
11848
11849
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
11850 return false;
11851
11852
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
11853 return false;
11854
11855
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
11856 718 return false;
11857
11858
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
11859 488 return false;
11860
11861
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
11862 return false;
11863
11864
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
11865 return false;
11866
11867
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
11868 return false;
11869
11870
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
11871 return false;
11872
11873 10295 return true;
11874 44658 }
11875
11876 35012 bool eTrap::clip()
11877 {
11878
2/2
✓ Branch 0 taken 1499 times.
✓ Branch 1 taken 33513 times.
35012 if(get_bit(quest_rules,qr_MEANPLACEDTRAPS))
11879 {
11880
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
✓ Branch 2 taken 342 times.
✓ Branch 3 taken 344 times.
✓ Branch 4 taken 263 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
1499 switch(dir)
11881 {
11882 case up:
11883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550 times.
550 if(y<=0) return true;
11884
11885 550 break;
11886
11887 case down:
11888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 342 times.
342 if(y>=160) return true;
11889
11890 342 break;
11891
11892 case left:
11893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if(x<=0) return true;
11894
11895 344 break;
11896
11897 case right:
11898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 263 times.
263 if(x>=240) return true;
11899
11900 263 break;
11901
11902 case l_up:
11903 if(y<=0||x<=0) return true;
11904
11905 break;
11906
11907 case l_down:
11908 if(y>=160||x<=0) return true;
11909
11910 break;
11911
11912 case r_up:
11913 if(y<=0||x>=240) return true;
11914
11915 break;
11916
11917 case r_down:
11918 if(y>=160||x>=240) return true;
11919
11920 break;
11921 }
11922
11923 1499 return false;
11924 }
11925 else
11926 {
11927
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
11928 {
11929 case up:
11930
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
11931
11932 3600 break;
11933
11934 case down:
11935
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
11936
11937 3984 break;
11938
11939 case left:
11940
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
11941
11942 12326 break;
11943
11944 case right:
11945
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
11946
11947 12743 break;
11948
11949 case l_up:
11950 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
11951
11952 break;
11953
11954 case l_down:
11955 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
11956
11957 break;
11958
11959 case r_up:
11960 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
11961
11962 break;
11963
11964 case r_down:
11965 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
11966
11967 break;
11968 }
11969
11970 32653 return false;
11971 }
11972 35012 }
11973
11974 499483 void eTrap::draw(BITMAP *dest)
11975 {
11976 499483 update_enemy_frame();
11977 499483 enemy::draw(dest);
11978 499483 }
11979
11980 2383 int32_t eTrap::takehit(weapon*,weapon*)
11981 {
11982 2383 return 0;
11983 }
11984
11985 280 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11986 280 {
11987 140 lasthit=-1;
11988 140 lasthitclk=0;
11989 140 mainguy=false;
11990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11991
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=2;
11992
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
11993 {
11994
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
60 dir=(x<=112)?right:left;
11995 60 }
11996 else
11997 {
11998
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
11999 }
12000
12001
2/4
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 140 times.
140 if(get_bit(quest_rules,qr_TRAPPOSFIX))
12002 {
12003 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
12004 }
12005
12006 //nets+((id==eTRAP_LR)?540:520);
12007 140 dummy_int[1]=0;
12008 140 SIZEflags = d->SIZEflags;
12009
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12010 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12011 // al_trace("Enemy txsz:%i\n", txsz);
12012
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12015
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12016
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12017
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12018 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12021 {
12022 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12023 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12024 }
12025
12026
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12027 140 }
12028
12029 83320 bool eTrap2::animate(int32_t index)
12030 {
12031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83320 times.
83320 if(switch_hooked) return enemy::animate(index);
12032
2/4
✓ Branch 0 taken 83320 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 83320 times.
83320 if(fallclk||drownclk) return enemy::animate(index);
12033
2/2
✓ Branch 0 taken 81360 times.
✓ Branch 1 taken 1960 times.
83320 if(clk<0)
12034 1960 return enemy::animate(index);
12035
12036
2/2
✓ Branch 0 taken 5158 times.
✓ Branch 1 taken 76202 times.
81360 if(clk==0)
12037 {
12038 5158 removearmos(x,y,ffcactivated);
12039 5158 }
12040
12041
2/2
✓ Branch 0 taken 76968 times.
✓ Branch 1 taken 4392 times.
81360 if(!get_bit(quest_rules,qr_PHANTOMPLACEDTRAPS))
12042 {
12043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
12044 {
12045 --lasthitclk;
12046 }
12047 else
12048 {
12049 4392 lasthit=-1;
12050 }
12051
12052 4392 bool hitenemy=false;
12053
12054
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
12055 {
12056
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
12057 {
12058
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
12059 {
12060 lasthit=j;
12061 lasthitclk=10;
12062 hitenemy=true;
12063 guys.spr(j)->lasthit=index;
12064 guys.spr(j)->lasthitclk=10;
12065 // guys.spr(j)->dir=guys.spr(j)->dir^1;
12066 }
12067 52704 }
12068 57096 }
12069
12070
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
12071 {
12072
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
12073 {
12074 48 lasthit=-1;
12075 48 lasthitclk=0;
12076 48 }
12077
12078
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(quest_rules,qr_MORESOUNDS))
12079 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12080
12081 48 dir=dir^1;
12082 48 }
12083
12084 4392 sprite::move(step);
12085 4392 }
12086 else
12087 {
12088
3/4
✓ Branch 0 taken 75261 times.
✓ Branch 1 taken 1707 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75261 times.
76968 if(!trapmove(dir) || clip())
12089 {
12090
1/2
✓ Branch 0 taken 1707 times.
✗ Branch 1 not taken.
1707 if(get_bit(quest_rules,qr_MORESOUNDS))
12091 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12092
12093 1707 dir=dir^1;
12094 1707 }
12095
12096 76968 sprite::move(step);
12097 }
12098
12099 81360 return enemy::animate(index);
12100 83320 }
12101
12102 81408 bool eTrap2::trapmove(int32_t ndir)
12103 {
12104
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 79530 times.
81408 if(tmpscr->flags2&fFLOATTRAPS)
12105 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
12106
12107 79530 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
12108 81408 }
12109
12110 79605 bool eTrap2::clip()
12111 {
12112
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 16303 times.
✓ Branch 4 taken 16539 times.
79605 switch(dir)
12113 {
12114 case up:
12115
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
12116
12117 23387 break;
12118
12119 case down:
12120
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
12121
12122 23376 break;
12123
12124 case left:
12125
1/2
✓ Branch 0 taken 16303 times.
✗ Branch 1 not taken.
16303 if(x<=0) return true;
12126
12127 16303 break;
12128
12129 case right:
12130
1/2
✓ Branch 0 taken 16539 times.
✗ Branch 1 not taken.
16539 if(x>=240) return true;
12131
12132 16539 break;
12133 }
12134
12135 79605 return false;
12136 79605 }
12137
12138 83330 void eTrap2::draw(BITMAP *dest)
12139 {
12140 83330 update_enemy_frame();
12141 83330 enemy::draw(dest);
12142 83330 }
12143
12144 526 int32_t eTrap2::takehit(weapon*,weapon*)
12145 {
12146 526 return 0;
12147 }
12148
12149 416 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12150 416 {
12151 //do not show "enemy appering" anim -DD
12152 208 clk=0;
12153 208 mainguy=false;
12154 208 clk2=-14;
12155 //Enemy Editor Size Tab
12156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12157 208 else hxofs = -2;
12158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12159 208 else hyofs = -2;
12160
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12161 208 else hxsz = 20;
12162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12163 208 else hysz=20;
12164
12165
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12166
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12167
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12168
1/4
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12170 {
12171 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12172 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12173 }
12174
12175
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12176 //nets+1640;
12177 208 }
12178
12179 71521 bool eRock::animate(int32_t index)
12180 {
12181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71521 times.
71521 if(switch_hooked) return enemy::animate(index);
12182
2/4
✓ Branch 0 taken 71521 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71521 times.
71521 if(fallclk||drownclk) return enemy::animate(index);
12183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71521 times.
71521 if(dying)
12184 return Dead(index);
12185
12186
2/2
✓ Branch 0 taken 66484 times.
✓ Branch 1 taken 5037 times.
71521 if(clk==0)
12187 {
12188 5037 removearmos(x,y,ffcactivated);
12189 5037 }
12190
12191
2/2
✓ Branch 0 taken 71119 times.
✓ Branch 1 taken 402 times.
71521 if(++clk2==0) // start it
12192 {
12193 402 x=zc_oldrand()&0xF0;
12194 402 y=0;
12195 402 clk3=0;
12196 402 clk2=zc_oldrand()&15;
12197 402 }
12198
12199
2/2
✓ Branch 0 taken 13144 times.
✓ Branch 1 taken 58377 times.
71521 if(clk2>16) // move it
12200 {
12201
2/2
✓ Branch 0 taken 56364 times.
✓ Branch 1 taken 2013 times.
58377 if(clk3<=0) // start bounce
12202 {
12203 2013 dir=zc_oldrand()&1;
12204
12205
2/2
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 229 times.
2013 if(x<32) dir=1;
12206
12207
2/2
✓ Branch 0 taken 1847 times.
✓ Branch 1 taken 166 times.
2013 if(x>208) dir=0;
12208 2013 }
12209
12210
2/2
✓ Branch 0 taken 56499 times.
✓ Branch 1 taken 1878 times.
58377 if(clk3<13+16)
12211 {
12212 56499 x += dir ? 1 : -1; //right, left
12213 56499 dummy_int[1]=dir;
12214
12215
2/2
✓ Branch 0 taken 4021 times.
✓ Branch 1 taken 52478 times.
56499 if(clk3<2)
12216 {
12217 4021 y-=2; //up
12218 4021 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12219 4021 }
12220
2/2
✓ Branch 0 taken 5996 times.
✓ Branch 1 taken 46482 times.
52478 else if(clk3<5)
12221 {
12222 5996 y--; //up
12223 5996 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12224 5996 }
12225
2/2
✓ Branch 0 taken 5959 times.
✓ Branch 1 taken 40523 times.
46482 else if(clk3<8)
12226 {
12227 5959 dummy_int[2]=(dummy_int[1]==1)?right:left;
12228 5959 }
12229
2/2
✓ Branch 0 taken 5911 times.
✓ Branch 1 taken 34612 times.
40523 else if(clk3<11)
12230 {
12231 5911 y++; //down
12232 5911 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12233 5911 }
12234 else
12235 {
12236 34612 y+=2; //down
12237 34612 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12238 }
12239
12240 56499 ++clk3;
12241 56499 }
12242
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 251 times.
1878 else if(y<176)
12243 1627 clk3=0; // next bounce
12244 else
12245 251 clk2 = -(zc_oldrand()&63); // back to top
12246 58377 }
12247
12248 71521 return enemy::animate(index);
12249 71521 }
12250
12251 14169 void eRock::drawshadow(BITMAP *dest, bool translucent)
12252 {
12253
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 12347 times.
14169 if(clk2>=0)
12254 {
12255 12347 int32_t tempy=yofs;
12256 12347 flip = 0;
12257 12347 int32_t fdiv = frate/4;
12258
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12259
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
12260 12347 efrate:((clk>=(frate>>1))?1:0);
12261 12347 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12262
12263 12347 yofs+=8;
12264
5/6
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 6539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12347 times.
✓ Branch 4 taken 5808 times.
✓ Branch 5 taken 6539 times.
12347 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12347 times.
12347 if(!shadow_overpit(this))
12266 12347 enemy::drawshadow(dest, translucent);
12267 12347 yofs=tempy;
12268 12347 }
12269 14169 }
12270
12271 71582 void eRock::draw(BITMAP *dest)
12272 {
12273
4/6
✓ Branch 0 taken 9822 times.
✓ Branch 1 taken 61760 times.
✓ Branch 2 taken 9822 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9822 times.
71582 if(clk2>=0 || fallclk||drownclk)
12274 {
12275 61760 int32_t tempdir=dir;
12276 61760 dir=dummy_int[2];
12277 61760 update_enemy_frame();
12278 61760 enemy::draw(dest);
12279 61760 dir=tempdir;
12280 61760 }
12281 71582 }
12282
12283 718 int32_t eRock::takehit(weapon*,weapon*)
12284 {
12285 718 return 0;
12286 }
12287
12288 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12289 60 {
12290 30 clk=0;
12291 30 mainguy=false;
12292 30 clk2=-14;
12293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12294 30 else hxofs= -10;
12295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12296 30 else hyofs=-10;
12297
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12298 30 else hxsz=36;
12299
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12300 30 else hysz=36;
12301
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12302 30 else hzsz=16; //can't be jumped
12303
12304
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12305
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12307
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12309 {
12310 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12311 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12312 }
12313
12314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12315 //nets+1680;
12316 30 }
12317
12318 4440 bool eBoulder::animate(int32_t index)
12319 {
12320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
12321
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
12322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
12323 return Dead(index);
12324
12325
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
12326 {
12327 290 removearmos(x,y,ffcactivated);
12328 290 }
12329
12330 zfix *vert;
12331
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_bit(quest_rules,qr_ENEMIESZAXIS) ? &z : &y;
12332
12333
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
12334 {
12335 32 x=zc_oldrand()&0xF0;
12336 32 y=-32;
12337 32 clk3=0;
12338 32 clk2=zc_oldrand()&15;
12339 32 }
12340
12341
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
12342 {
12343
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
12344 {
12345 131 dir=zc_oldrand()&1;
12346
12347
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
12348
12349
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
12350 131 }
12351
12352
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
12353 {
12354 3487 x += dir ? 1 : -1; //right, left
12355 3487 dummy_int[1]=dir;
12356
12357
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
12358 {
12359 261 y-=2; //up
12360 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12361 261 }
12362
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
12363 {
12364 382 y--; //up
12365 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12366 382 }
12367
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
12368 {
12369 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
12370 376 }
12371
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
12372 {
12373 367 y++; //down
12374 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12375 367 }
12376 else
12377 {
12378 2101 y+=2; //down
12379 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12380 }
12381
12382 3487 ++clk3;
12383 3487 }
12384
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
12385 101 clk3=0; // next bounce
12386 else
12387 10 clk2 = -(zc_oldrand()&63); // back to top
12388 3598 }
12389
12390 4440 return enemy::animate(index);
12391 4440 }
12392
12393 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
12394 {
12395
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
12396 {
12397 3868 int32_t tempy=yofs;
12398 3868 flip = 0;
12399 3868 int32_t f2=((clk<<2)/frate)<<1;
12400 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12401
5/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3868 times.
✓ Branch 4 taken 1729 times.
✓ Branch 5 taken 2139 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12402
12403 3868 yofs+=8;
12404 3868 xofs-=8;
12405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12406 3868 enemy::drawshadow(dest, translucent);
12407 3868 xofs+=16;
12408 3868 ++shadowtile;
12409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12410 3868 enemy::drawshadow(dest, translucent);
12411 3868 yofs+=16;
12412 3868 shadowtile+=20;
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12414 3868 enemy::drawshadow(dest, translucent);
12415 3868 xofs-=16;
12416 3868 --shadowtile;
12417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12418 3868 enemy::drawshadow(dest, translucent);
12419 3868 xofs+=8;
12420 3868 yofs=tempy;
12421 3868 }
12422 4440 }
12423
12424 4440 void eBoulder::draw(BITMAP *dest)
12425 {
12426
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
12427 {
12428 3868 int32_t tempdir=dir;
12429 3868 dir=dummy_int[2];
12430 3868 update_enemy_frame();
12431 3868 dir=tempdir;
12432 3868 xofs-=8;
12433 3868 yofs-=8;
12434 3868 drawblock(dest,15);
12435 3868 xofs+=8;
12436 3868 yofs+=8;
12437 // enemy::draw(dest);
12438 3868 }
12439 4440 }
12440
12441 int32_t eBoulder::takehit(weapon*,weapon*)
12442 {
12443 return 0;
12444 }
12445
12446 4254 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
12447
3/4
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1613 times.
2127 minRange(get_bit(quest_rules, qr_BROKENSTATUES) ? 0 : Clk)
12448 4254 {
12449 /* fixing
12450 hp=1;
12451 */
12452 2127 mainguy=false;
12453
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2120 times.
2127 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12454 2127 hclk=clk; // the "no fire" range
12455 2127 clk=0;
12456 2127 clk3=96;
12457 2127 timer=0;
12458
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2120 times.
2127 if(o_tile==0)
12459 {
12460 2120 superman=1;
12461 2120 hxofs=1000;
12462 2120 }
12463 2127 SIZEflags = d->SIZEflags;
12464
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2127 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12465 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12466 // al_trace("Enemy txsz:%i\n", txsz);
12467
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2127 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12468
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2127 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12469
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2127 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2127 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12471
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12472
1/2
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
2127 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12473 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12476 {
12477 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12478 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12479 }
12480
12481
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2127 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12482 2127 }
12483
12484 1509951 bool eProjectile::animate(int32_t index)
12485 {
12486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1509951 times.
1509951 if(switch_hooked) return enemy::animate(index);
12487
2/4
✓ Branch 0 taken 1509951 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1509951 times.
1509951 if(fallclk||drownclk) return enemy::animate(index);
12488
2/2
✓ Branch 0 taken 1502702 times.
✓ Branch 1 taken 7249 times.
1509951 if(clk==0)
12489 {
12490 7249 removearmos(x,y,ffcactivated);
12491 7249 }
12492
12493 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12494 1509951 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12495
12496
4/4
✓ Branch 0 taken 493988 times.
✓ Branch 1 taken 1015963 times.
✓ Branch 2 taken 270279 times.
✓ Branch 3 taken 223709 times.
1509951 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12497 {
12498 223709 dir=down;
12499 223709 }
12500
4/4
✓ Branch 0 taken 824870 times.
✓ Branch 1 taken 461372 times.
✓ Branch 2 taken 270279 times.
✓ Branch 3 taken 554591 times.
1286242 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12501 {
12502 554591 dir=right;
12503 554591 }
12504
4/4
✓ Branch 0 taken 506887 times.
✓ Branch 1 taken 224764 times.
✓ Branch 2 taken 270279 times.
✓ Branch 3 taken 236608 times.
731651 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
12505 {
12506 236608 dir=up;
12507 236608 }
12508 else
12509 {
12510 495043 dir=left;
12511 }
12512
12513
3/4
✓ Branch 0 taken 1509951 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 789235 times.
✓ Branch 3 taken 720716 times.
1509951 if(!stunclk && ++clk3>80)
12514 {
12515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 720716 times.
720716 if(dmisc1==9) // Breath type
12516 {
12517 if(timer==0)
12518 {
12519 unsigned r=zc_oldrand();
12520
12521 if(!(r&63))
12522 {
12523 timer=zc_oldrand()%50+50;
12524 }
12525 }
12526
12527 if(timer>0)
12528 {
12529 if(timer%4==0)
12530 {
12531 FireBreath(false);
12532 }
12533
12534 if(--timer==0)
12535 {
12536 clk3=0;
12537 }
12538 }
12539 }
12540
12541 else // Not breath type
12542 {
12543 720716 unsigned r=zc_oldrand();
12544
12545
4/4
✓ Branch 0 taken 11277 times.
✓ Branch 1 taken 709439 times.
✓ Branch 2 taken 835 times.
✓ Branch 3 taken 10442 times.
720716 if(!(r&63) && !HeroInRange(minRange))
12546 {
12547 10442 FireWeapon();
12548
12549
3/4
✓ Branch 0 taken 8071 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10503 if(get_bit(quest_rules, qr_BROKENSTATUES)==0 &&
12550
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8010 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8071 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
12551 {
12552
2/2
✓ Branch 0 taken 7611 times.
✓ Branch 1 taken 460 times.
8071 if(!((r>>7)&15))
12553 {
12554 460 x-=4;
12555 460 FireWeapon();
12556 460 x+=4;
12557 460 }
12558 8071 }
12559
12560 10442 clk3=0;
12561 10442 }
12562 }
12563 720716 }
12564
12565 1509951 return enemy::animate(index);
12566 1509951 }
12567
12568 1515526 void eProjectile::draw(BITMAP *dest)
12569 {
12570 1515526 update_enemy_frame();
12571 1515526 enemy::draw(dest);
12572 1515526 }
12573
12574 46 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12575 46 {
12576 23 hxofs=1000;
12577 23 }
12578
12579 4492 void eTrigger::draw(BITMAP *dest)
12580 {
12581 4492 update_enemy_frame();
12582 4492 enemy::draw(dest);
12583 4492 }
12584
12585 void eTrigger::death_sfx()
12586 {
12587 //silent death
12588 }
12589
12590 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12591 {
12592 o_tile+=wpnsbuf[iwNPCs].tile;
12593 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12594 SIZEflags = d->SIZEflags;
12595 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12596 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12597 // al_trace("Enemy txsz:%i\n", txsz);
12598 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12599 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12600 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12601 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12602 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12603 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12604 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12606 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12607 {
12608 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12609 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12610 }
12611
12612 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12613 }
12614
12615 bool eNPC::animate(int32_t index)
12616 {
12617 if(switch_hooked) return enemy::animate(index);
12618 if(dying)
12619 return Dead(index);
12620
12621 if(clk==0)
12622 {
12623 removearmos(x,y,ffcactivated);
12624 }
12625
12626 switch(dmisc2)
12627 {
12628 case 0:
12629 {
12630 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12631 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12632
12633 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12634 {
12635 dir=down;
12636 }
12637
12638 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12639 {
12640 dir=right;
12641 }
12642 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
12643 {
12644 dir=up;
12645 }
12646 else
12647 {
12648 dir=left;
12649 }
12650 }
12651 break;
12652
12653 case 1:
12654 halting_walk(rate, homing, 0, hrate, 48);
12655
12656 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
12657 {
12658 newdir(rate, homing, 0);
12659 clk2=48;
12660 ++misc;
12661 }
12662
12663 if(clk2==0)
12664 misc=0;
12665
12666 break;
12667 }
12668
12669 return enemy::animate(index);
12670 }
12671
12672 void eNPC::draw(BITMAP *dest)
12673 {
12674 update_enemy_frame();
12675 enemy::draw(dest);
12676 }
12677
12678 int32_t eNPC::takehit(weapon*,weapon*)
12679 {
12680 return 0;
12681 }
12682
12683 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12684 188 {
12685
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
12686 {
12687 94 o_tile=clk;
12688 94 cs=id>>12;
12689 94 }
12690
12691 94 id=id&0xFFF;
12692 94 clk=0;
12693
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
12694 94 mainguy=false;
12695 94 SIZEflags = d->SIZEflags;
12696
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12697 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12698 // al_trace("Enemy txsz:%i\n", txsz);
12699
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12701
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12703
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12704
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12705 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12706
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12708 {
12709 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12710 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12711 }
12712
12713
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12714 94 }
12715
12716 81 void eSpinTile::facehero()
12717 {
12718
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
12719 {
12720
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
12721 1 dir = up;
12722 else
12723 dir = down;
12724 1 }
12725 else
12726 {
12727 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12728 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12729
12730
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
12731 {
12732 12 dir=l_down;
12733 12 }
12734
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
12735 {
12736 1 dir=down;
12737 1 }
12738
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
12739 {
12740 12 dir=r_down;
12741 12 }
12742
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
12743 {
12744 6 dir=right;
12745 6 }
12746
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
12747 {
12748 17 dir=r_up;
12749 17 }
12750
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
12751 {
12752 8 dir=up;
12753 8 }
12754
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
12755 {
12756 6 dir=l_up;
12757 6 }
12758 else
12759 {
12760 18 dir=left;
12761 }
12762 }
12763 81 }
12764
12765
12766 15539 bool eSpinTile::animate(int32_t index)
12767 {
12768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
12769
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
12770
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
12771 {
12772 1152 return Dead(index);
12773 }
12774
12775
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
12776 {
12777 1241 removearmos(x,y,ffcactivated);
12778 1241 }
12779
12780 14387 ++misc;
12781
12782
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
12783 {
12784 81 facehero();
12785 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12786 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
12787 81 angular=true;
12788 81 angle=ddir;
12789 81 step=zslongToFix(dstep*100);
12790 81 }
12791
12792
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
12793 52 kickbucket();
12794
12795 14387 sprite::move(step);
12796 14387 return enemy::animate(index);
12797 15539 }
12798
12799 15457 void eSpinTile::draw(BITMAP *dest)
12800 {
12801 15457 update_enemy_frame();
12802 15457 y-=(misc>>4);
12803 15457 yofs+=2;
12804 15457 enemy::draw(dest);
12805 15457 yofs-=2;
12806 15457 y+=(misc>>4);
12807 15457 }
12808
12809 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
12810 {
12811 15457 flip = 0;
12812 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
12813 15457 yofs+=4;
12814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
12815 15457 enemy::drawshadow(dest, translucent);
12816 15457 yofs-=4;
12817 15457 }
12818
12819 3074 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
12820 3074 {
12821 //these are here to bypass compiler warnings about unused arguments
12822 1537 Clk=Clk;
12823 1537 mainguy=false;
12824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
1537 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12825 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
12826 {
12827 clk=1;
12828 }*/
12829 //nets+880;
12830 1537 SIZEflags = d->SIZEflags;
12831
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1537 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12832 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12833 // al_trace("Enemy txsz:%i\n", txsz);
12834
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1537 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12835
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1537 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12836
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1537 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12837
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1537 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12838
1/2
✓ Branch 0 taken 1537 times.
✗ Branch 1 not taken.
1537 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12839
1/2
✓ Branch 0 taken 1537 times.
✗ Branch 1 not taken.
1537 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12840 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12841
1/4
✓ Branch 0 taken 1537 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1537 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
1537 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12843 {
12844 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12845 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12846 }
12847
12848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1537 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12849 1537 }
12850
12851 371492 void eZora::facehero()
12852 {
12853
2/2
✓ Branch 0 taken 6205 times.
✓ Branch 1 taken 365287 times.
371492 if(Hero.x-x==0)
12854 {
12855 6205 dir=(Hero.y+8<y)?up:down;
12856 6205 }
12857 else
12858 {
12859 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12860 365287 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12861
12862
4/4
✓ Branch 0 taken 76242 times.
✓ Branch 1 taken 289045 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 47454 times.
365287 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
12863 {
12864 47454 dir=l_down;
12865 47454 }
12866
4/4
✓ Branch 0 taken 54307 times.
✓ Branch 1 taken 263526 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 25519 times.
317833 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
12867 {
12868 25519 dir=down;
12869 25519 }
12870
4/4
✓ Branch 0 taken 73753 times.
✓ Branch 1 taken 218561 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 44965 times.
292314 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
12871 {
12872 44965 dir=r_down;
12873 44965 }
12874
4/4
✓ Branch 0 taken 98242 times.
✓ Branch 1 taken 149107 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 69454 times.
247349 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
12875 {
12876 69454 dir=right;
12877 69454 }
12878
4/4
✓ Branch 0 taken 78596 times.
✓ Branch 1 taken 99299 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 49808 times.
177895 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
12879 {
12880 49808 dir=r_up;
12881 49808 }
12882
4/4
✓ Branch 0 taken 51731 times.
✓ Branch 1 taken 76356 times.
✓ Branch 2 taken 28788 times.
✓ Branch 3 taken 22943 times.
128087 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
12883 {
12884 22943 dir=up;
12885 22943 }
12886
4/4
✓ Branch 0 taken 71427 times.
✓ Branch 1 taken 33717 times.
✓ Branch 2 taken 42639 times.
✓ Branch 3 taken 28788 times.
105144 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
12887 {
12888 42639 dir=l_up;
12889 42639 }
12890 else
12891 {
12892 62505 dir=left;
12893 }
12894 }
12895 371492 }
12896
12897 533752 bool eZora::animate(int32_t index)
12898 {
12899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 533752 times.
533752 if(switch_hooked) return enemy::animate(index);
12900
2/2
✓ Branch 0 taken 1854 times.
✓ Branch 1 taken 531898 times.
533752 if(dying)
12901 1854 return Dead(index);
12902
12903
2/2
✓ Branch 0 taken 528431 times.
✓ Branch 1 taken 3467 times.
531898 if(clk==0)
12904 {
12905 3467 removearmos(x,y,ffcactivated);
12906 3467 }
12907
12908
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 531867 times.
531898 if(watch)
12909 {
12910 31 ++clock_zoras[id];
12911 31 return true;
12912 }
12913
12914
2/2
✓ Branch 0 taken 160375 times.
✓ Branch 1 taken 371492 times.
531867 if(get_bit(quest_rules,qr_NEWENEMYTILES))
12915 {
12916 371492 facehero();
12917 371492 }
12918
12919
6/6
✓ Branch 0 taken 3208 times.
✓ Branch 1 taken 3082 times.
✓ Branch 2 taken 2586 times.
✓ Branch 3 taken 516940 times.
✓ Branch 4 taken 4111 times.
✓ Branch 5 taken 1940 times.
531867 switch(clk)
12920 {
12921 case 0: // reposition him
12922 {
12923 4111 int32_t t=0;
12924 4111 int32_t pos2=zc_oldrand()%160 + 16;
12925 4111 bool placed=false;
12926
12927
4/4
✓ Branch 0 taken 4088 times.
✓ Branch 1 taken 19943 times.
✓ Branch 2 taken 12388 times.
✓ Branch 3 taken 3467 times.
24031 while(!placed && t<160)
12928 {
12929 12388 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
12930
5/6
✓ Branch 0 taken 4169 times.
✓ Branch 1 taken 8219 times.
✓ Branch 2 taken 4169 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 322 times.
✓ Branch 5 taken 3444 times.
16154 if(watertype && ((editorflags & ENEMY_FLAG6) ||
12931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4169 times.
4169 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
12932
3/4
✓ Branch 0 taken 4169 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3766 times.
✓ Branch 3 taken 3766 times.
4169 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
12933 {
12934 3444 x=(pos2&15)<<4;
12935 3444 y=pos2&0xF0;
12936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3444 times.
3444 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
12937 3444 hxofs=1000; // avoid hit detection
12938 3444 stunclk=0;
12939 3444 placed=true;
12940 3444 }
12941
12942 19920 pos2+=19;
12943
12944
2/2
✓ Branch 0 taken 17573 times.
✓ Branch 1 taken 2347 times.
19920 if(pos2>=176)
12945 2347 pos2-=160;
12946
12947 19920 ++t;
12948 }
12949
12950
3/4
✓ Branch 0 taken 3444 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3444 times.
3467 if(!placed || whistleclk>=88) // can't place him, he's gone
12951 23 return true;
12952
12953 }
12954 3444 break;
12955
12956 case 35:
12957
2/2
✓ Branch 0 taken 2243 times.
✓ Branch 1 taken 965 times.
3208 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
12958 {
12959 965 dir=(Hero.y+8<y)?up:down;
12960 965 }
12961
12962 3208 hxofs=0;
12963 3208 break;
12964
12965 case 35+19:
12966 3082 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
12967 3082 sfx(wpnsfx(wpn),pan(int32_t(x)));
12968 3082 break;
12969
12970 case 35+66:
12971 2586 hxofs=1000;
12972 2586 break;
12973
12974 case 198:
12975 1940 clk=-1;
12976 1940 break;
12977 }
12978
12979 531200 return enemy::animate(index);
12980 533108 }
12981
12982 533508 void eZora::draw(BITMAP *dest)
12983 {
12984
2/2
✓ Branch 0 taken 10338 times.
✓ Branch 1 taken 523170 times.
533508 if(clk<3)
12985 10338 return;
12986
12987 523170 update_enemy_frame();
12988 523170 enemy::draw(dest);
12989 533508 }
12990
12991 bool eZora::isSubmerged() const
12992 {
12993 return ( clk < 3 );
12994 }
12995
12996
4/8
✓ Branch 0 taken 23161 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23161 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23161 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23161 times.
✗ Branch 7 not taken.
69483 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12997 46322 {
12998 23161 multishot= timer = fired = dashing = 0;
12999 23161 hashero = false;
13000 23161 dummy_bool[0]=false;
13001 23161 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
13002
5/6
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 23026 times.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 72 times.
✓ Branch 5 taken 63 times.
23161 if(dmisc9==e9tARMOS && zc_oldrand()&1)
13003 {
13004
2/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
72 step=zslongToFix(dmisc10*100);
13005
13006
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 60 times.
72 if(anim==aARMOS4) o_tile+=20;
13007 72 }
13008
13009
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 23026 times.
23161 if(flags & guy_fadeflicker)
13010 {
13011 135 clk=0;
13012 135 superman = 1;
13013 135 fading=fade_flicker;
13014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13015 135 dir=down;
13016
13017
4/6
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 74 times.
135 if(!canmove(down,(zfix)8,spw_none,false))
13018
3/6
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61 times.
✗ Branch 5 not taken.
61 clk3=int32_t(13.0/step);
13019 135 }
13020
2/2
✓ Branch 0 taken 23025 times.
✓ Branch 1 taken 1 times.
23026 else if(flags & guy_fadeinstant)
13021 {
13022 1 clk=0;
13023 1 }
13024
13025
1/2
✓ Branch 0 taken 23161 times.
✗ Branch 1 not taken.
23161 shadowdistance = 0;
13026 23161 clk4 = clk5 = 0;
13027 //nets+2380;
13028 23161 SIZEflags = d->SIZEflags;
13029
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23161 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13030 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13031 // al_trace("Enemy txsz:%i\n", txsz);
13032
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23161 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13033
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23161 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
13034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23161 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
13035
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23161 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13036
1/2
✓ Branch 0 taken 23161 times.
✗ Branch 1 not taken.
23161 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13037
1/2
✓ Branch 0 taken 23161 times.
✗ Branch 1 not taken.
23161 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13038 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13039
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23161 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
23161 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13041 {
13042 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13043 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13044 }
13045
13046
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23161 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23161 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13047 23161 }
13048
13049 8871974 bool eStalfos::animate(int32_t index)
13050 {
13051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8871974 times.
8871974 if(switch_hooked) return enemy::animate(index);
13052
3/4
✓ Branch 0 taken 8871832 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8871832 times.
8871974 if(fallclk||drownclk)
13053 {
13054 142 return enemy::animate(index);
13055 }
13056
2/2
✓ Branch 0 taken 194123 times.
✓ Branch 1 taken 8677709 times.
8871832 if(dying)
13057 {
13058
2/2
✓ Branch 0 taken 194092 times.
✓ Branch 1 taken 31 times.
194123 if(hashero)
13059 {
13060 31 Hero.setEaten(0);
13061 31 hashero=false;
13062 31 }
13063
13064
10/14
✓ Branch 0 taken 17924 times.
✓ Branch 1 taken 176199 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 16784 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
194123 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
13065 {
13066 49 hp=-1000;
13067
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
13068 49 Ewpns.add(ew);
13069 49 ew->fakez = fakez;
13070
13071
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
13072 {
13073 49 ew->step=0;
13074 49 ew->id=wpn;
13075 49 ew->misc=50;
13076 49 ew->clk=48;
13077 49 }
13078
13079 49 fired=true;
13080 49 }
13081
6/6
✓ Branch 0 taken 89310 times.
✓ Branch 1 taken 104764 times.
✓ Branch 2 taken 72334 times.
✓ Branch 3 taken 16976 times.
✓ Branch 4 taken 72316 times.
✓ Branch 5 taken 18 times.
194074 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
13082 {
13083
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
13084 {
13085 1 int32_t wpn2 = wpn+dmisc3;
13086
13087
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
13088 {
13089 wpn2=wpn;
13090 }
13091
13092 1 dummy_bool[0]=true;
13093 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
13094 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13095 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
13096 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13097 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
13098 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13099 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
13100 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13101 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
13102 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13103 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
13104 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13105 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
13106 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13107 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
13108 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13109 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
13110 1 }
13111 18 }
13112
13113 194123 KillWeapon();
13114 194123 return Dead(index);
13115 }
13116 //vire split
13117 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
13118 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
13119
13/14
✓ Branch 0 taken 10952 times.
✓ Branch 1 taken 8666757 times.
✓ Branch 2 taken 10952 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 10803 times.
✓ Branch 6 taken 779556 times.
✓ Branch 7 taken 7898004 times.
✓ Branch 8 taken 778299 times.
✓ Branch 9 taken 1257 times.
✓ Branch 10 taken 4200 times.
✓ Branch 11 taken 774099 times.
✓ Branch 12 taken 751 times.
✓ Branch 13 taken 3449 times.
8677709 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
13120 {
13121 900 stop_bgsfx(index);
13122 900 int32_t kids = guys.Count();
13123 900 int32_t id2=dmisc3;
13124
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 900 times.
2686 for(int32_t i=0; i < dmisc4; i++)
13125 {
13126 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13127
4/6
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1786 times.
1786 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
13128 1786 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13129 1786 }
13130
13131
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
900 if(itemguy) // Hand down the carried item
13132 {
13133 guycarryingitem = guys.Count()-1;
13134 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13135 itemguy = false;
13136 }
13137
13138
1/2
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
900 if(hashero)
13139 {
13140 Hero.setEaten(0);
13141 hashero=false;
13142 }
13143
13144
4/4
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 751 times.
✓ Branch 3 taken 135 times.
900 if(deadsfx > 0 && dmisc2==e2tSPLIT)
13145 135 sfx(deadsfx,pan(int32_t(x)));
13146
13147 900 return true;
13148 }
13149 /*
13150 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
13151 {
13152 stop_bgsfx(index);
13153 int32_t kids = guys.Count();
13154 int32_t id2=dmisc3;
13155
13156 for(int32_t i=0; i < dmisc4; i++)
13157 {
13158 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13159 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
13160 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13161 }
13162
13163 if(itemguy) // Hand down the carried item
13164 {
13165 guycarryingitem = guys.Count()-1;
13166 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13167 itemguy = false;
13168 }
13169
13170 if(hashero)
13171 {
13172 Hero.setEaten(0);
13173 hashero=false;
13174 }
13175
13176 return true;
13177 }
13178 */
13179
2/2
✓ Branch 0 taken 11022 times.
✓ Branch 1 taken 8665787 times.
8676809 if(fading)
13180 {
13181
2/2
✓ Branch 0 taken 198 times.
✓ Branch 1 taken 10824 times.
11022 if(++clk4 > 60)
13182 {
13183 198 clk4=0;
13184 198 superman=0;
13185 198 fading=0;
13186
13187
4/6
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 135 times.
198 if(flags2&cmbflag_armos && z==0 && fakez == 0)
13188 {
13189 //if a custom size (not 16px by 16px)
13190
13191 //if a custom size (not 16px by 16px)
13192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if (ffcactivated)
13193 removearmosffc(ffcactivated-1);
13194 else
13195 {
13196
4/8
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 135 times.
135 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13197 {
13198 //zprint("spawn big enemy from armos\n");
13199 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13200 for(int32_t dx = 0; dx < tysz; dx ++)
13201 {
13202 for(int32_t dy = 0; dy < tysz; dy++)
13203 {
13204 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
13205 did_armos = false;
13206 }
13207 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
13208 did_armos = false;
13209 }
13210 for(int32_t dy = 0; dy < tysz; dy ++)
13211 {
13212 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
13213 did_armos = false;
13214 }
13215 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
13216 }
13217 135 else removearmos(x,y);
13218 }
13219 /*
13220 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13221 {
13222 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13223 for(int32_t dx = 0; dx < hxsz; dx += 16)
13224 {
13225 for(int32_t dy = 0; dy < hysz; dy += 16)
13226 {
13227 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
13228 did_armos = false;
13229 }
13230 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13231 did_armos = false;
13232 }
13233 for(int32_t dy = 0; dy < hysz; dy += 16)
13234 {
13235 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
13236 did_armos = false;
13237 }
13238 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13239 }
13240 else removearmos(x,y,ffcactivated);
13241 */
13242
13243 135 }
13244
13245 198 clk2=0;
13246
13247 198 newdir();
13248 198 }
13249 10824 else return enemy::animate(index);
13250 198 }
13251
6/8
✓ Branch 0 taken 30924 times.
✓ Branch 1 taken 8634863 times.
✓ Branch 2 taken 30924 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30924 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28959 times.
✓ Branch 7 taken 1965 times.
8665787 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
13252 1965 removearmos(x,y,ffcactivated);
13253
13254
13255
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 8663445 times.
8665985 if(hashero)
13256 {
13257 2540 Hero.setX(x);
13258 2540 Hero.setY(y);
13259 2540 ++clk2;
13260
13261
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
13262 {
13263
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
13264 {
13265 case e7tEATITEMS:
13266 {
13267
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
13268 {
13269
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
13270 1 game->set_item(i, false);
13271 256 }
13272
13273 1 break;
13274 }
13275
13276 case e7tEATMAGIC:
13277 game->change_dmagic(-1*game->get_magicdrainrate());
13278 break;
13279
13280 case e7tEATRUPEES:
13281 game->change_drupy(-1);
13282 break;
13283 }
13284
13285 51 clk2=0;
13286 51 }
13287
13288
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
13289 2335 --clk;
13290 2540 }
13291
4/4
✓ Branch 0 taken 676625 times.
✓ Branch 1 taken 7986820 times.
✓ Branch 2 taken 393431 times.
✓ Branch 3 taken 283194 times.
8663445 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
13292 {
13293 // Movement engine
13294
4/6
✓ Branch 0 taken 453967 times.
✓ Branch 1 taken 7926284 times.
✓ Branch 2 taken 2248 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7924036 times.
✗ Branch 5 not taken.
8380251 if(clk>=0) switch(id>>12)
13295 {
13296 case 0: // Normal movement
13297
13298 /*
13299 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
13300 {
13301 // Overloading clk4 (Tribble clock) here...
13302 step=17/100.0;
13303 if(clk4<32) misc=1;
13304 else if(clk4<48) misc=2;
13305 else if(clk4<300) { misc=3; step = dstep/100.0; }
13306 else if(clk4<316) misc=2;
13307 else if(clk4<412) misc=1;
13308 else if(clk4<540) { misc=0; step=0; }
13309 else clk4=0;
13310 if(clk4==48) clk=0;
13311 hxofs=(misc>=2)?0:1000;
13312 if (dmisc9==e9tLEEVER)
13313 variable_walk(rate, homing, 0);
13314 else
13315 variable_walk_8(rate, homing, 4, 0);
13316 break;
13317 }
13318 */
13319
4/4
✓ Branch 0 taken 7738675 times.
✓ Branch 1 taken 185361 times.
✓ Branch 2 taken 268937 times.
✓ Branch 3 taken 7469738 times.
7924036 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
13320 {
13321 454298 vire_hop();
13322 454298 break;
13323 }
13324
2/2
✓ Branch 0 taken 549014 times.
✓ Branch 1 taken 6920724 times.
7469738 else if(dmisc9==e9tROPE) //Rope charge
13325 {
13326
9/10
✓ Branch 0 taken 531592 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 76944 times.
✓ Branch 3 taken 454648 times.
✓ Branch 4 taken 70223 times.
✓ Branch 5 taken 6721 times.
✓ Branch 6 taken 69507 times.
✓ Branch 7 taken 716 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 69507 times.
549014 if(!fired && dashing && !stunclk && !watch && !frozenclock)
13327 {
13328
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 67135 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
69507 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
13329 {
13330
13331
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_bit(quest_rules,qr_BOMBCHUSUPERBOMB) )
13332 {
13333 14 hp=-1000;
13334
13335
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13336 {
13337
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
13338 14 Ewpns.add(ew);
13339 14 ew->fakez = fakez;
13340
13341
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
13342 {
13343 14 ew->step=0;
13344 14 ew->id=wpn+dmisc3;
13345 14 ew->misc=50;
13346 14 ew->clk=48;
13347 14 }
13348
13349 14 fired=true;
13350 14 }
13351 else
13352 {
13353 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
13354 Ewpns.add(ew);
13355 ew->fakez = fakez;
13356
13357 if(wpn==ewSBomb || wpn==ewBomb)
13358 {
13359 ew->step=0;
13360 ew->id=wpn;
13361 ew->misc=50;
13362 ew->clk=48;
13363 }
13364
13365 fired=true;
13366 }
13367 14 }
13368
13369 else
13370 {
13371 1 hp=-1000;
13372
13373 int32_t wpn2;
13374
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13375 1 wpn2=wpn;
13376 else
13377 wpn2=wpn;
13378
13379
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
13380 1 Ewpns.add(ew);
13381 1 ew->fakez = fakez;
13382
13383
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
13384 {
13385 1 ew->step=0;
13386 1 ew->id=wpn2;
13387 1 ew->misc=50;
13388 1 ew->clk=48;
13389 1 }
13390
13391 1 fired=true;
13392 }
13393 15 }
13394 69507 }
13395
13396 549014 charge_attack();
13397 549014 break;
13398 }
13399 /*
13400 * Boomerang-throwers have a halt count of 1
13401 * Zols have a halt count of (zc_oldrand()&7)<<4
13402 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
13403 * Everything else has 48
13404 */
13405 else
13406 {
13407
2/2
✓ Branch 0 taken 364907 times.
✓ Branch 1 taken 6555817 times.
6920724 if(wpn==ewBrang) // Goriya
13408 {
13409 364907 halting_walk(rate,homing,0,hrate, 1);
13410 364907 }
13411
4/4
✓ Branch 0 taken 6524758 times.
✓ Branch 1 taken 31059 times.
✓ Branch 2 taken 2535520 times.
✓ Branch 3 taken 3989238 times.
6555817 else if(dmisc9==e9tNORMAL && wpn==0)
13412 {
13413
2/2
✓ Branch 0 taken 551326 times.
✓ Branch 1 taken 3437912 times.
3989238 if(dmisc2==e2tSPLITHIT) // Zol
13414 {
13415 551326 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
13416 551326 }
13417
4/4
✓ Branch 0 taken 1118569 times.
✓ Branch 1 taken 2319343 times.
✓ Branch 2 taken 1026079 times.
✓ Branch 3 taken 92490 times.
3437912 else if(frate<=8 && starting_hp==1) // Gel
13418 {
13419 92490 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
13420 92490 }
13421 else // Other
13422 {
13423 3345422 halting_walk(rate,homing,0,hrate, 48);
13424 }
13425 3989238 }
13426 else // Other
13427 {
13428 2566579 halting_walk(rate,homing,0,hrate, 48);
13429 }
13430 }
13431
13432 //if not in midair, and Hero's swinging sword is nearby, jump.
13433 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
13434 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
13435 {
13436 facehero(false);
13437 sclk=16+((dir^1)<<8);
13438 fall=-FEATHERJUMP;
13439 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
13440 }*/
13441 6920724 break;
13442
13443 // Following cases are for just after creation-by-splitting.
13444 case 1:
13445
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 559 times.
2248 if(misc==1)
13446 {
13447 559 dir=up;
13448 559 step=8;
13449 559 }
13450
13451
2/2
✓ Branch 0 taken 538 times.
✓ Branch 1 taken 1710 times.
2248 if(misc<=2)
13452 {
13453 1710 move(step);
13454
13455
2/2
✓ Branch 0 taken 1379 times.
✓ Branch 1 taken 331 times.
1710 if(!canmove(dir,(zfix)0,0,false))
13456 331 dir=down;
13457 1710 }
13458
13459
2/2
✓ Branch 0 taken 1710 times.
✓ Branch 1 taken 538 times.
2248 if(misc==3)
13460 {
13461
2/2
✓ Branch 0 taken 199 times.
✓ Branch 1 taken 339 times.
538 if(canmove(right,(zfix)16,0,false))
13462 339 x+=16;
13463 538 }
13464
13465 2248 ++misc;
13466 2248 break;
13467
13468 case 2:
13469 if(misc==1)
13470 {
13471 dir=down;
13472 step=8;
13473 }
13474
13475 if(misc<=2)
13476 {
13477 move(step);
13478 /*
13479 if(!canmove(dir,(zfix)0,0,false))
13480 dir=up;
13481 */
13482 }
13483
13484 if(misc==3)
13485 {
13486 if(canmove(left,(zfix)16,0,false))
13487 x-=16;
13488 }
13489
13490 ++misc;
13491 break;
13492
13493 default:
13494 if(misc==1)
13495 {
13496 dir=(zc_oldrand()%4);
13497 step=8;
13498 }
13499
13500 if(misc<=2)
13501 {
13502 move(step);
13503
13504 if(!canmove(dir,(zfix)0,0,false))
13505 dir=dir^1;
13506 }
13507
13508 if(misc==3)
13509 {
13510 if(dir >= left && canmove(dir,(zfix)16,0,false))
13511 x+=(dir==left ? -16 : 16);
13512 }
13513
13514 ++misc;
13515 break;
13516 7926284 }
13517
13518
4/4
✓ Branch 0 taken 16116 times.
✓ Branch 1 taken 8364135 times.
✓ Branch 2 taken 15578 times.
✓ Branch 3 taken 538 times.
8380251 if(id>>12 && misc>=4) //recently spawned by a split enemy
13519 {
13520 538 id&=0xFFF;
13521 538 step = zslongToFix(dstep*100);
13522
13523
1/2
✓ Branch 0 taken 538 times.
✗ Branch 1 not taken.
538 if(x<32) x=32;
13524
13525
2/2
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 11 times.
538 if(x>208) x=208;
13526
13527
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 18 times.
538 if(y<32) y=32;
13528
13529
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 5 times.
538 if(y>128) y=128;
13530
13531 538 misc=3;
13532 538 }
13533 8380251 }
13534 else
13535 {
13536 //sfx(wpnsfx(wpn),pan(int32_t(x)));
13537
1/2
✓ Branch 0 taken 283194 times.
✗ Branch 1 not taken.
283194 if(clk2>2) clk2--;
13538 }
13539
13540 // Fire Zol
13541
7/8
✓ Branch 0 taken 3516357 times.
✓ Branch 1 taken 5149628 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3509723 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
8665985 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
13542 {
13543 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
13544 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
13545
13546 47 int32_t i=Ewpns.Count()-1;
13547 47 weapon *ew = (weapon*)(Ewpns.spr(i));
13548
13549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
13550 {
13551 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
13552 if ( ew->do_animation ) ew->tile+=ew->aframe;
13553 }
13554 47 }
13555 // Goriya
13556
14/16
✓ Branch 0 taken 676625 times.
✓ Branch 1 taken 7989313 times.
✓ Branch 2 taken 308336 times.
✓ Branch 3 taken 368289 times.
✓ Branch 4 taken 301226 times.
✓ Branch 5 taken 7110 times.
✓ Branch 6 taken 277971 times.
✓ Branch 7 taken 23255 times.
✓ Branch 8 taken 277971 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 275265 times.
✓ Branch 11 taken 2706 times.
✓ Branch 12 taken 275265 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 271194 times.
✓ Branch 15 taken 4071 times.
8665938 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
13557 {
13558 4071 misc=index+100;
13559
7/14
✓ Branch 0 taken 4071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4071 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4071 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4071 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4071 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4071 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4071 times.
✗ Branch 13 not taken.
4071 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
13560 4071 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
13561
13562
2/2
✓ Branch 0 taken 3916 times.
✓ Branch 1 taken 155 times.
4071 if(dmisc1==2)
13563 {
13564 155 int32_t ndir=dir;
13565
13566
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
13567 {
13568 4 ndir=(Hero.y+8<y)?up:down;
13569 4 }
13570 else //turn to face Hero
13571 {
13572 double _MSVC2022_tmp1, _MSVC2022_tmp2;
13573 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
13574
13575
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
13576 {
13577 9 ndir=down;
13578 9 }
13579
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
13580 {
13581 41 ndir=right;
13582 41 }
13583
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
13584 {
13585 33 ndir=up;
13586 33 }
13587 else
13588 {
13589 68 ndir=left;
13590 }
13591 }
13592
13593 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
13594
13595
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
13596 {
13597 153 dir=ndir;
13598 153 }
13599 155 }
13600 4071 }
13601
15/16
✓ Branch 0 taken 8627990 times.
✓ Branch 1 taken 33877 times.
✓ Branch 2 taken 118588 times.
✓ Branch 3 taken 8543279 times.
✓ Branch 4 taken 104007 times.
✓ Branch 5 taken 14581 times.
✓ Branch 6 taken 89300 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 88643 times.
✓ Branch 9 taken 657 times.
✓ Branch 10 taken 80765 times.
✓ Branch 11 taken 7878 times.
✓ Branch 12 taken 80765 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 79821 times.
8661867 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
13602
3/3
✓ Branch 0 taken 14755 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
79821 switch(dmisc1)
13603 {
13604 case e1tCONSTANT: //Deathnut
13605 {
13606 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
13607
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
13608 {
13609 1343 clk5=0;
13610 1343 fired=false;
13611 1343 }
13612
13613 64165 clk5+=(zc_oldrand()&3);
13614
13615
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
13616 {
13617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
13618
13619
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
13620 {
13621
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
13622 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
13623 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
13624 1449 fired=true;
13625 1449 }
13626 26135 }
13627
13628 64165 break;
13629 }
13630
13631 case e1tFIREOCTO: //Fire Octo
13632 901 timer=zc_oldrand()%50+50;
13633 901 break;
13634
13635 default:
13636 14755 FireWeapon();
13637 14755 break;
13638 79821 }
13639
13640 /* Fire again if:
13641 * - clk2 about to run out
13642 * - not already double-firing (dmisc1 is 1)
13643 * - not carrying Hero
13644 * - one in 0xF chance
13645 */
13646
8/10
✓ Branch 0 taken 340119 times.
✓ Branch 1 taken 8325866 times.
✓ Branch 2 taken 3015 times.
✓ Branch 3 taken 337104 times.
✓ Branch 4 taken 3015 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3015 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 194 times.
✓ Branch 9 taken 2821 times.
8665985 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
13647 {
13648 #if 1
13649 194 newdir(rate, homing, grumble);
13650 #else
13651 dir^=2;
13652 #endif
13653 194 clk2=28;
13654 194 ++multishot;
13655 194 }
13656
13657
2/2
✓ Branch 0 taken 2124710 times.
✓ Branch 1 taken 6541275 times.
8665985 if(clk2==0)
13658 {
13659 6541275 multishot = 0;
13660 6541275 }
13661
13662
2/2
✓ Branch 0 taken 8601868 times.
✓ Branch 1 taken 64117 times.
8665985 if(timer) //Fire Octo
13663 {
13664 64117 clk2=15; //this keeps the octo in place until he's done firing
13665
13666
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
13667 {
13668 15704 FireBreath(false);
13669 15704 }
13670
13671 64117 --timer;
13672 64117 }
13673
13674
2/2
✓ Branch 0 taken 8489156 times.
✓ Branch 1 taken 176829 times.
8665985 if(dmisc2==e2tTRIBBLE)
13675 176829 ++clk4;
13676
13677
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 8663745 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 8665378 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
8665985 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
13678 {
13679 607 int32_t kids = guys.Count();
13680 607 int32_t id2=dmisc3;
13681
13682
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
13683 {
13684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
13685 {
13686
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
13687 {
13688 guycarryingitem = guys.Count()-1;
13689 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13690 itemguy = false;
13691 }
13692
13693 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13694 607 }
13695 607 }
13696
13697
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
13698 {
13699 Hero.setEaten(0);
13700 hashero=false;
13701 }
13702
13703 607 stop_bgsfx(index);
13704 607 return true;
13705 }
13706
13707 8665378 return enemy::animate(index);
13708 8871974 }
13709
13710 9181975 void eStalfos::draw(BITMAP *dest)
13711 {
13712 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
13713 {
13714 clk4--; //Kludge
13715 return;
13716 }*/
13717
13718 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
13719 {
13720 cs = dcset;
13721 }*/
13722 9181975 update_enemy_frame();
13723
13724
7/8
✓ Branch 0 taken 9181833 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9181833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9145858 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9181975 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
13725 {
13726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
13727 2890 }
13728
13729 9181975 enemy::draw(dest);
13730 9181975 }
13731
13732 1969465 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
13733 {
13734 1969465 int32_t tempy=yofs;
13735
13736 /*
13737 if (clk6 && dir>=left && !get_bit(quest_rules,qr_ENEMIESZAXIS)) {
13738 flip = 0;
13739 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13740 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
13741 shadowtile = wpnsbuf[spr_shadow].tile+f2;
13742 yofs+=(((int32_t)y+17)&0xF0)-y;
13743 yofs+=8;
13744 }
13745 */
13746
3/4
✓ Branch 0 taken 1888692 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1969465 times.
✗ Branch 3 not taken.
1969465 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_ENEMIESZAXIS))
13747 {
13748 flip = 0;
13749 int32_t fdiv = frate/4;
13750 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13751
13752 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13753 efrate:((clk>=(frate>>1))?1:0);
13754 shadowtile = wpnsbuf[spr_shadow].tile;
13755
13756 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13757 {
13758 shadowtile+=f2;
13759 }
13760 else
13761 {
13762 shadowtile+=f2?1:0;
13763 }
13764
13765 yofs+=shadowdistance;
13766 yofs+=8;
13767 }
13768
3/4
✓ Branch 0 taken 1888692 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1969465 times.
✗ Branch 3 not taken.
1969465 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_POLVIRE_NO_SHADOW))
13769 {
13770 flip = 0;
13771 int32_t fdiv = frate/4;
13772 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13773
13774 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13775 efrate:((clk>=(frate>>1))?1:0);
13776 shadowtile = wpnsbuf[spr_shadow].tile;
13777
13778 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13779 {
13780 shadowtile+=f2;
13781 }
13782 else
13783 {
13784 shadowtile+=f2?1:0;
13785 }
13786 }
13787
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1969323 times.
1969465 if(!shadow_overpit(this))
13788 1969323 enemy::drawshadow(dest, translucent);
13789 1969465 yofs=tempy;
13790 1969465 }
13791
13792 91861 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
13793 {
13794 91861 int32_t wpnId = w->id;
13795 91861 int32_t wpnDir = w->dir;
13796
13797
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 91285 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
91861 if(wpnId==wHammer && shield && (flags & guy_bkshield)
13798
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
13799
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
13800 {
13801 119 shield = false;
13802 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
13803
13804
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 105 times.
119 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13805 14 o_tile=s_tile;
13806 119 }
13807
13808 91861 int32_t ret = enemy::takehit(w,realweap);
13809
13810
4/4
✓ Branch 0 taken 11242 times.
✓ Branch 1 taken 80619 times.
✓ Branch 2 taken 10025 times.
✓ Branch 3 taken 1217 times.
91861 if(sclk && dmisc2==e2tSPLITHIT)
13811 1217 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
13812
13813 91861 return ret;
13814 }
13815
13816 549014 void eStalfos::charge_attack()
13817 {
13818
2/2
✓ Branch 0 taken 4914 times.
✓ Branch 1 taken 544100 times.
549014 if(slide())
13819 4914 return;
13820
13821
9/12
✓ Branch 0 taken 544100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 544100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 527957 times.
✓ Branch 5 taken 16143 times.
✓ Branch 6 taken 509892 times.
✓ Branch 7 taken 18065 times.
✓ Branch 8 taken 505726 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 505726 times.
544100 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
13822 38374 return;
13823
13824
2/2
✓ Branch 0 taken 20208 times.
✓ Branch 1 taken 485518 times.
505726 if(clk3<=0)
13825 {
13826 20208 fix_coords(true);
13827
13828
2/2
✓ Branch 0 taken 5611 times.
✓ Branch 1 taken 14597 times.
20208 if(!dashing)
13829 {
13830 14597 int32_t ldir = lined_up(7,false);
13831
13832
4/4
✓ Branch 0 taken 1453 times.
✓ Branch 1 taken 13144 times.
✓ Branch 2 taken 1233 times.
✓ Branch 3 taken 220 times.
14597 if(ldir!=-1 && canmove(ldir,false))
13833 {
13834 1233 dir=ldir;
13835 1233 dashing=true;
13836 1233 step=zslongToFix(dstep*100)+1;
13837 1233 }
13838 13364 else newdir(4,0,0);
13839 14597 }
13840
13841
2/2
✓ Branch 0 taken 19466 times.
✓ Branch 1 taken 742 times.
20208 if(!canmove(dir,false))
13842 {
13843 742 step=zslongToFix(dstep*100);
13844 742 newdir();
13845 742 dashing=false;
13846 742 }
13847
13848 20208 zfix div = step;
13849
13850
1/2
✓ Branch 0 taken 20208 times.
✗ Branch 1 not taken.
20208 if(div == 0)
13851 div = 1;
13852
13853 20208 clk3=(int32_t)(16.0/div);
13854 20208 return;
13855 }
13856
13857 485518 move(step);
13858 485518 --clk3;
13859 549014 }
13860
13861 454298 void eStalfos::vire_hop()
13862 {
13863 //if ( sclk > 0 ) return; //Don't hop during knockback.
13864
13865 // if(dmisc9!=e9tPOLSVOICE)
13866 // {
13867 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13868 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13869 // return; //the enemy should split if it is sliding!
13870 // //else sclk=0; //might need this here, too. -Z
13871 // }
13872
2/2
✓ Branch 0 taken 185361 times.
✓ Branch 1 taken 268937 times.
454298 if(dmisc9!=e9tPOLSVOICE)
13873 {
13874
2/2
✓ Branch 0 taken 180047 times.
✓ Branch 1 taken 5314 times.
185361 if(sclk!=0)
13875 {
13876
2/2
✓ Branch 0 taken 1471 times.
✓ Branch 1 taken 3843 times.
5314 if (dmisc2==e2tSPLITHIT) return;
13877 //return;
13878 3843 }
13879 183890 }
13880 268937 else sclk=0;
13881
13882
8/12
✓ Branch 0 taken 452827 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 452827 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 445104 times.
✓ Branch 5 taken 7723 times.
✓ Branch 6 taken 431175 times.
✓ Branch 7 taken 13929 times.
✓ Branch 8 taken 431175 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 431175 times.
452827 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
13883 21652 return;
13884
13885 431175 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
13886 431175 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
13887
13888 431175 y=floor_y;
13889
13890
2/2
✓ Branch 0 taken 416939 times.
✓ Branch 1 taken 14236 times.
431175 if(clk3<=0)
13891 {
13892 14236 fix_coords();
13893
13894 //z=0;
13895 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
13896 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
13897
9/10
✓ Branch 0 taken 2828 times.
✓ Branch 1 taken 11408 times.
✓ Branch 2 taken 2503 times.
✓ Branch 3 taken 325 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2409 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14236 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
13898 11827 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
13899
13900
2/2
✓ Branch 0 taken 2828 times.
✓ Branch 1 taken 11408 times.
14236 if(clk2<=0)
13901 {
13902 //z=0;
13903
6/6
✓ Branch 0 taken 10437 times.
✓ Branch 1 taken 971 times.
✓ Branch 2 taken 10193 times.
✓ Branch 3 taken 244 times.
✓ Branch 4 taken 7420 times.
✓ Branch 5 taken 2773 times.
11408 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
13904 {
13905
13906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8635 times.
8635 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
13907 /*if (dmisc9==e9tPOLSVOICE )
13908 {
13909 zprint2("polsvoice jump_width is: %d\n", jump_width);
13910 zprint2("polsvoice raw step is: %d\n", step);
13911 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
13912 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
13913 }
13914 else
13915 {
13916 zprint2("vire jump_width is: %d\n", jump_width);
13917 zprint2("vire raw step is: %d\n", step);
13918 zprint2("vire step.getInt() is: %d\n", step.getInt());
13919 zprint2("setting clk2 on vire to: %d\n", clk2);
13920 }
13921 */
13922 8635 }
13923 11408 }
13924
13925
4/4
✓ Branch 0 taken 5792 times.
✓ Branch 1 taken 8444 times.
✓ Branch 2 taken 2619 times.
✓ Branch 3 taken 3173 times.
14236 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
13926 {
13927 3173 clk2=int32_t((16.0*jump_width)/step.getFloat());
13928 3173 }
13929
13930 14236 clk3=int32_t(16.0/step.getFloat());
13931 14236 }
13932
13933 431175 --clk3;
13934
13935
3/4
✓ Branch 0 taken 173768 times.
✓ Branch 1 taken 257407 times.
✓ Branch 2 taken 173768 times.
✗ Branch 3 not taken.
431175 if(dmisc9==e9tPOLSVOICE || clk2>0)
13936 431175 move(step);
13937
13938 431175 floor_y=y;
13939 431175 clk2--;
13940
13941 //if we're in the middle of a jump
13942
6/6
✓ Branch 0 taken 336102 times.
✓ Branch 1 taken 95073 times.
✓ Branch 2 taken 142182 times.
✓ Branch 3 taken 193920 times.
✓ Branch 4 taken 65955 times.
✓ Branch 5 taken 76227 times.
431175 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
13943 {
13944 259875 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
13945
13946
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 162791 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
259875 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
13947 {
13948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
13949 90933 else z=h;
13950 90933 }
13951 else
13952 {
13953 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
13954 //y-=h;
13955 168942 y=floor_y-h;
13956 168942 shadowdistance=h;
13957 }
13958 259875 }
13959 else
13960 171300 shadowdistance = 0;
13961 454298 }
13962
13963 51 void eStalfos::eathero()
13964 {
13965
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
13966 {
13967 32 hashero=true;
13968 32 y=floor_y;
13969 32 z=0;
13970
13971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
13972 {
13973 Hero.setX(x);
13974 Hero.setY(y);
13975 }
13976 else
13977 {
13978 32 x=Hero.getX();
13979 32 y=Hero.getY();
13980 }
13981
13982 32 clk2=0;
13983 32 }
13984 51 }
13985
13986 951890 bool eStalfos::WeaponOut()
13987 {
13988
2/2
✓ Branch 0 taken 1705421 times.
✓ Branch 1 taken 397502 times.
2102923 for(int32_t i=0; i<Ewpns.Count(); i++)
13989 {
13990
3/4
✓ Branch 0 taken 554388 times.
✓ Branch 1 taken 1151033 times.
✓ Branch 2 taken 554388 times.
✗ Branch 3 not taken.
1705421 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
13991 {
13992 554388 return true;
13993 }
13994
13995 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
13996 stop_sfx(bgsfx);
13997 */
13998 1151033 }
13999
14000 397502 return false;
14001 951890 }
14002
14003 194123 void eStalfos::KillWeapon()
14004 {
14005
2/2
✓ Branch 0 taken 194123 times.
✓ Branch 1 taken 179385 times.
373508 for(int32_t i=0; i<Ewpns.Count(); i++)
14006 {
14007
4/4
✓ Branch 0 taken 150605 times.
✓ Branch 1 taken 28780 times.
✓ Branch 2 taken 150087 times.
✓ Branch 3 taken 518 times.
179385 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
14008 {
14009 //only kill this Goriya's boomerang -DD
14010
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 225 times.
518 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
14011 {
14012 225 Ewpns.del(i);
14013 225 }
14014 518 }
14015 179385 }
14016
14017
4/4
✓ Branch 0 taken 16976 times.
✓ Branch 1 taken 177147 times.
✓ Branch 2 taken 8450 times.
✓ Branch 3 taken 8526 times.
194123 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
14018 {
14019 8450 stop_sfx(WAV_BRANG);
14020 8450 }
14021 194123 }
14022
14023 void eStalfos::break_shield()
14024 {
14025 if(!shield)
14026 return;
14027
14028 flags&=~(inv_front | inv_back | inv_left | inv_right);
14029 shield=false;
14030
14031 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
14032 o_tile=s_tile;
14033 }
14034
14035 11182 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14036 11182 {
14037
1/2
✓ Branch 0 taken 5591 times.
✗ Branch 1 not taken.
5591 dir=(zc_oldrand()&7)+8;
14038
1/2
✓ Branch 0 taken 5591 times.
✗ Branch 1 not taken.
5591 step=0;
14039 5591 movestatus=1;
14040
3/4
✓ Branch 0 taken 4635 times.
✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4635 times.
5591 if (dmisc1 != 1 && dmisc19 > 0)
14041 {
14042 step = dmisc19/100.0;
14043 movestatus = 1;
14044 }
14045
1/2
✓ Branch 0 taken 5591 times.
✗ Branch 1 not taken.
5591 if (dmisc1 == 2) movestatus=2;
14046 5591 c=0;
14047 5591 SIZEflags = d->SIZEflags;
14048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
5591 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
14049
1/2
✓ Branch 0 taken 5591 times.
✗ Branch 1 not taken.
5591 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14050
14051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
5591 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hxsz=12;
14052
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5591 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14053
14054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
5591 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
14055
1/2
✓ Branch 0 taken 5591 times.
✗ Branch 1 not taken.
5591 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14056
14057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
5591 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hysz=8;
14058
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5591 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14059
14060
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5591 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14061 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
14062 // al_trace("Enemy txsz:%i\n", txsz);
14063
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5591 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14064
14065
14066
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5591 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14067
14068
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5591 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
14069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
5591 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14070 {
14071 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14072 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14073 }
14074
14075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5591 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5591 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
14076 5591 clk4=0;
14077 //nets;
14078 5591 dummy_int[1]=0;
14079 5591 }
14080
14081 1654617 bool eKeese::animate(int32_t index)
14082 {
14083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1654617 times.
1654617 if(switch_hooked) return enemy::animate(index);
14084
2/4
✓ Branch 0 taken 1654617 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654617 times.
1654617 if(fallclk||drownclk) return enemy::animate(index);
14085
2/2
✓ Branch 0 taken 62474 times.
✓ Branch 1 taken 1592143 times.
1654617 if(dying)
14086 62474 return Dead(index);
14087
14088
2/2
✓ Branch 0 taken 1581657 times.
✓ Branch 1 taken 10486 times.
1592143 if(clk==0)
14089 {
14090 10486 removearmos(x,y,ffcactivated);
14091 10486 }
14092
14093
2/2
✓ Branch 0 taken 368335 times.
✓ Branch 1 taken 1223808 times.
1592143 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
14094 {
14095 368335 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
14096 368335 }
14097 else
14098 {
14099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1223808 times.
1223808 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
14100 1223808 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
14101 }
14102
14103
2/2
✓ Branch 0 taken 34829 times.
✓ Branch 1 taken 1557314 times.
1592143 if(dmisc2 == e2tKEESETRIB)
14104 {
14105
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34829 times.
✓ Branch 2 taken 34759 times.
✓ Branch 3 taken 70 times.
34829 if(++clk4==(dmisc20>0?dmisc20:256))
14106 {
14107
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 52 times.
70 if(!m_walkflag(x,y,0, dir))
14108 {
14109 52 int32_t kids = guys.Count();
14110 52 bool success = false;
14111 52 int32_t id2=dmisc3;
14112 52 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
14113
14114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if(success)
14115 {
14116
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(itemguy) // Hand down the carried item
14117 {
14118 guycarryingitem = guys.Count()-1;
14119 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
14120 itemguy = false;
14121 }
14122
14123 52 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
14124 52 }
14125
14126 52 stop_bgsfx(index);
14127 52 return true;
14128 }
14129 else
14130 {
14131 18 clk4=0;
14132 }
14133 18 }
14134 34777 }
14135 // Keese Tribbles stay on the ground, so there's no problem when they transform.
14136
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1074146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1557314 else if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
14137 {
14138
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_bit(quest_rules,qr_OLD_KEESE_Z_AXIS))
14139 {
14140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
14141 {
14142 fakez=int32_t(step/zslongToFix(dstep*100));
14143 // Some variance in keese flight heights when away from Hero
14144 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14145
14146 }
14147 else
14148 {
14149 483168 z=int32_t(step/zslongToFix(dstep*100));
14150 // Some variance in keese flight heights when away from Hero
14151
2/2
✓ Branch 0 taken 392397 times.
✓ Branch 1 taken 90771 times.
483168 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14152 }
14153 483168 }
14154 else
14155 {
14156 if (moveflags & FLAG_USE_FAKE_Z)
14157 {
14158 fakez=int32_t(step/zslongToFix(dstep*100));
14159 // Some variance in keese flight heights when away from Hero
14160 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14161
14162 }
14163 else
14164 {
14165 z=int32_t(step/zslongToFix(dstep*100));
14166 // Some variance in keese flight heights when away from Hero
14167 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14168 }
14169 }
14170 483168 }
14171
14172 1592091 return enemy::animate(index);
14173 1654617 }
14174
14175 431730 void eKeese::drawshadow(BITMAP *dest, bool translucent)
14176 {
14177 431730 int32_t tempy=yofs;
14178 431730 flip = 0;
14179 431730 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
14180
14181
2/2
✓ Branch 0 taken 155463 times.
✓ Branch 1 taken 276267 times.
431730 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
14182
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 129208 times.
431730 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
14183 {
14184 129208 yofs+=int32_t(step/zslongToFix(dstep*10));
14185 129208 }
14186
14187
6/6
✓ Branch 0 taken 428136 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 125614 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
431730 if(!shadow_overpit(this) && (!get_bit(quest_rules,qr_ENEMIESZAXIS) || step > 0))
14188 420066 enemy::drawshadow(dest, translucent);
14189 431730 yofs=tempy;
14190 431730 }
14191
14192 3779030 void eKeese::draw(BITMAP *dest)
14193 {
14194 3779030 update_enemy_frame();
14195 3779030 enemy::draw(dest);
14196 3779030 }
14197
14198 11174 void eWizzrobe::submerge(bool set)
14199 {
14200
2/2
✓ Branch 0 taken 11146 times.
✓ Branch 1 taken 28 times.
11174 if(get_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING))
14201 {
14202 11146 hxofs = set?1000:0;
14203 11146 return;
14204 }
14205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
14206 28 submerged = set;
14207
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
14208 14 hxofs+=1000;
14209 14 else hxofs -= 1000;
14210 11174 }
14211 4192 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14212 4192 {
14213 2096 hxofs = 0;
14214 2096 submerged = false;
14215
2/2
✓ Branch 0 taken 911 times.
✓ Branch 1 taken 1185 times.
2096 switch(dmisc1)
14216 {
14217 case 0:
14218
1/2
✓ Branch 0 taken 1185 times.
✗ Branch 1 not taken.
1185 submerge(true);
14219 1185 fading=fade_invisible;
14220 // Set clk to just before the 'reappear' threshold
14221
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1185 times.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 225 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 960 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 225 times.
1185 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
14222 1185 break;
14223
14224 default:
14225 911 dir=(loadside==right)?right:left;
14226 911 misc=-3;
14227 911 break;
14228 }
14229
14230 //netst+2880;
14231 2096 charging=false;
14232 2096 firing=false;
14233 2096 fclk=0;
14234
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 911 times.
2096 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
14235 2096 SIZEflags = d->SIZEflags;
14236
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2096 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14237 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14238 // al_trace("Enemy txsz:%i\n", txsz);
14239
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2096 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2096 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14241
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2096 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2096 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14243
1/2
✓ Branch 0 taken 2096 times.
✗ Branch 1 not taken.
2096 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
14244 {
14245 hxofs = (submerged?hxofs:0)+d->hxofs;
14246 }
14247
1/2
✓ Branch 0 taken 2096 times.
✗ Branch 1 not taken.
2096 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14248 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2096 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
2096 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14251 {
14252 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14253 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14254 }
14255
14256
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2096 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2096 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
14257 2096 }
14258
14259 994530 bool eWizzrobe::animate(int32_t index)
14260 {
14261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 994530 times.
994530 if(switch_hooked) return enemy::animate(index);
14262
2/4
✓ Branch 0 taken 994530 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 994530 times.
994530 if(fallclk||drownclk) return enemy::animate(index);
14263
2/2
✓ Branch 0 taken 21632 times.
✓ Branch 1 taken 972898 times.
994530 if(dying)
14264 {
14265 21632 return Dead(index);
14266 }
14267
14268
2/2
✓ Branch 0 taken 941809 times.
✓ Branch 1 taken 31089 times.
972898 if(clk==0)
14269 {
14270 31089 removearmos(x,y,ffcactivated);
14271 31089 }
14272
14273
2/2
✓ Branch 0 taken 494064 times.
✓ Branch 1 taken 478834 times.
972898 if(dmisc1) // Floating
14274 {
14275 494064 wizzrobe_attack();
14276 494064 }
14277 else // Teleporting
14278 {
14279
5/6
✓ Branch 0 taken 473481 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 470771 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
478834 if(watch || (!get_bit(quest_rules, qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
14280 {
14281 5353 fading=0;
14282 5353 submerge(false);
14283 5353 solid_update(false);
14284 5353 }
14285
8/8
✓ Branch 0 taken 457745 times.
✓ Branch 1 taken 2806 times.
✓ Branch 2 taken 2438 times.
✓ Branch 3 taken 2363 times.
✓ Branch 4 taken 2326 times.
✓ Branch 5 taken 2022 times.
✓ Branch 6 taken 1951 times.
✓ Branch 7 taken 1830 times.
473481 else switch(clk)
14286 {
14287 case 0:
14288
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2325 times.
2806 if(!dmisc2)
14289 {
14290 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
14291 // but should not appear on dungeon walls.
14292
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1916 times.
2325 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
14293
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1871 times.
1916 else if (editorflags&ENEMY_FLAG5)
14294 {
14295 //2.10 Windrobe
14296 //randomise location and face Hero
14297 45 int32_t t=0;
14298 45 bool placed=false;
14299
14300
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 45 times.
96 while(!placed && t<160)
14301 {
14302
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isdungeon())
14303 {
14304 51 x=((zc_oldrand()%12)+2)*16;
14305 51 y=((zc_oldrand()%7)+2)*16;
14306 51 }
14307 else
14308 {
14309 x=((zc_oldrand()%14)+1)*16;
14310 y=((zc_oldrand()%9)+1)*16;
14311 }
14312
14313
6/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 45 times.
101 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14314 {
14315 45 placed=true;
14316 45 }
14317
14318 51 ++t;
14319 }
14320
14321
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 31 times.
45 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14322 {
14323
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(y<Hero.getY())
14324 {
14325 9 dir=down;
14326 9 }
14327 else
14328 {
14329 5 dir=up;
14330 }
14331 14 }
14332 else
14333 {
14334
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(x<Hero.getX())
14335 {
14336 15 dir=right;
14337 15 }
14338 else
14339 {
14340 16 dir=left;
14341 }
14342 }
14343
14344
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!placed) // can't place him, he's gone
14345 return true;
14346
14347
14348 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
14349 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
14350 45 }
14351 1871 else place_on_axis(true, dmisc4!=0);
14352 2325 }
14353 else
14354 {
14355 481 int32_t t=0;
14356 481 bool placed=false;
14357
14358
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
14359 {
14360
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
14361 {
14362 624 x=((zc_oldrand()%12)+2)*16;
14363 624 y=((zc_oldrand()%7)+2)*16;
14364 624 }
14365 else
14366 {
14367 17 x=((zc_oldrand()%14)+1)*16;
14368 17 y=((zc_oldrand()%9)+1)*16;
14369 }
14370
14371
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14372 {
14373 481 placed=true;
14374 481 }
14375
14376 641 ++t;
14377 }
14378
14379
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14380 {
14381
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
14382 {
14383 97 dir=down;
14384 97 }
14385 else
14386 {
14387 62 dir=up;
14388 }
14389 159 }
14390 else
14391 {
14392
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
14393 {
14394 166 dir=right;
14395 166 }
14396 else
14397 {
14398 156 dir=left;
14399 }
14400 }
14401
14402
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
14403 return true;
14404 }
14405
14406 2806 fading=fade_flicker;
14407 2806 submerge(false);
14408 2806 solid_update(false);
14409 2806 break;
14410
14411 case 64:
14412 2438 fading=0;
14413 2438 charging=true;
14414 2438 break;
14415
14416 case 73:
14417 2363 charging=false;
14418 2363 firing=40;
14419 2363 break;
14420
14421 case 83:
14422 2326 wizzrobe_attack_for_real();
14423 2326 break;
14424
14425 case 119:
14426 2022 firing=false;
14427 2022 charging=true;
14428 2022 break;
14429
14430 case 128:
14431 1951 fading=fade_flicker;
14432 1951 charging=false;
14433 1951 break;
14434
14435 case 146:
14436 1830 fading=fade_invisible;
14437 1830 submerge(true);
14438 1830 solid_update(false);
14439
14440 [[fallthrough]];
14441 default:
14442
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 459575 times.
✓ Branch 2 taken 456765 times.
✓ Branch 3 taken 2810 times.
459575 if(clk>=(146+zc_max(0,dmisc5)))
14443 2810 clk=-1;
14444
14445 459575 break;
14446 }
14447 }
14448
14449 972898 return enemy::animate(index);
14450 994530 }
14451
14452 3775 void eWizzrobe::wizzrobe_attack_for_real()
14453 {
14454
1/2
✓ Branch 0 taken 3775 times.
✗ Branch 1 not taken.
3775 if(wpn==0) // Edited enemies
14455 return;
14456
14457
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 3002 times.
3775 if(dmisc2 == 0) //normal weapon
14458 {
14459 3002 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
14460 3002 sfx(WAV_WAND,pan(int32_t(x)));
14461 3002 }
14462
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 450 times.
773 else if(dmisc2 == 1) // ring of fire
14463 {
14464 323 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
14465 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14466 323 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
14467 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14468 323 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
14469 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14470 323 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
14471 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14472 323 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
14473 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14474 323 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
14475 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14476 323 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
14477 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14478 323 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
14479 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14480 323 sfx(WAV_FIRE,pan(int32_t(x)));
14481
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 283 times.
323 if (get_bit(quest_rules, qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
14482 else
14483 {
14484
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
14485 {
14486 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
14487
14488 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
14489 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
14490 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
14491 case ewRock: sfx(51,pan(int32_t(x))); break;
14492 case ewMagic: sfx(32,pan(int32_t(x))); break;
14493 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14494 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14495 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14496 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14497 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
14498 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
14499 case ewWind: sfx(32,pan(int32_t(x))); break;
14500 case ewFlame2: sfx(13,pan(int32_t(x))); break;
14501 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
14502 case ewIce: sfx(44,pan(int32_t(x))); break;
14503 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
14504 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
14505
14506 }
14507 }
14508 323 }
14509
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
14510 {
14511 436 int32_t bc=0;
14512
14513
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
14514 {
14515
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
14516 {
14517 2804 ++bc;
14518 2804 }
14519 5394 }
14520
14521
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
14522 {
14523 428 int32_t kids = guys.Count();
14524 428 int32_t bats=(zc_oldrand()%3)+1;
14525
14526
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
14527 {
14528 // Summon bats (or anything)
14529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
14530 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14531 868 }
14532
14533 428 sfx(WAV_FIRE,pan(int32_t(x)));
14534 428 }
14535 436 }
14536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
14537 {
14538
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
14539 {
14540 return;
14541 }
14542
14543 14 int32_t kids = guys.Count();
14544
14545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
14546 {
14547 14 int32_t newguys=(zc_oldrand()%3)+1;
14548 14 bool summoned=false;
14549
14550
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
14551 {
14552 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
14553 25 int32_t x2=0;
14554 25 int32_t y2=0;
14555
14556
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
14557 {
14558 27 x2=16*((zc_oldrand()%12)+2);
14559 27 y2=16*((zc_oldrand()%7)+2);
14560
14561
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
14562 {
14563
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
14564 {
14565 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14566
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
14567 {
14568 ((enemy*)guys.spr(kids+i))->fakez = 64;
14569 ((enemy*)guys.spr(kids+i))->z = 0;
14570 }
14571 25 }
14572
14573 25 summoned=true;
14574 25 break;
14575 }
14576 2 }
14577 25 }
14578
14579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
14580 {
14581 14 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
14582 14 }
14583 14 }
14584 14 }
14585 3775 }
14586
14587
14588 494064 void eWizzrobe::wizzrobe_attack()
14589 {
14590
9/12
✓ Branch 0 taken 479296 times.
✓ Branch 1 taken 14768 times.
✓ Branch 2 taken 479296 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460681 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 458530 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 458530 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 458530 times.
494064 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
14591 35534 return;
14592
14593
3/8
✓ Branch 0 taken 440270 times.
✓ Branch 1 taken 18260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440270 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
458530 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
14594 {
14595 18260 fix_coords();
14596
14597
5/5
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 591 times.
✓ Branch 2 taken 8571 times.
✓ Branch 3 taken 4700 times.
✓ Branch 4 taken 2106 times.
18260 switch(misc)
14598 {
14599 case 1: //walking
14600
2/2
✓ Branch 0 taken 3582 times.
✓ Branch 1 taken 1118 times.
4700 if(!m_walkflag(x,y,spw_door, dir))
14601 1118 misc=0;
14602 else
14603 {
14604 3582 clk3=16;
14605
14606
2/2
✓ Branch 0 taken 3093 times.
✓ Branch 1 taken 489 times.
3582 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
14607 {
14608 489 wizzrobe_newdir(0);
14609 489 }
14610 }
14611
14612 4700 break;
14613
14614 case 2: //phasing
14615 {
14616 2106 int32_t jx=x;
14617 2106 int32_t jy=y;
14618 2106 int32_t jdir=-1;
14619
14620
5/5
✓ Branch 0 taken 1068 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 261 times.
✓ Branch 4 taken 262 times.
2106 switch(zc_oldrand()&7)
14621 {
14622 case 0:
14623 274 jx-=32;
14624 274 jy-=32;
14625 274 jdir=15;
14626 274 break;
14627
14628 case 1:
14629 241 jx+=32;
14630 241 jy-=32;
14631 241 jdir=9;
14632 241 break;
14633
14634 case 2:
14635 261 jx+=32;
14636 261 jy+=32;
14637 261 jdir=11;
14638 261 break;
14639
14640 case 3:
14641 262 jx-=32;
14642 262 jy+=32;
14643 262 jdir=13;
14644 262 break;
14645 }
14646
14647
10/10
✓ Branch 0 taken 1038 times.
✓ Branch 1 taken 1068 times.
✓ Branch 2 taken 924 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 860 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 749 times.
✓ Branch 7 taken 111 times.
✓ Branch 8 taken 621 times.
✓ Branch 9 taken 128 times.
2106 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
14648 {
14649 621 misc=3;
14650 621 clk3=32;
14651 621 dir=jdir;
14652 621 break;
14653 }
14654 1485 }
14655 [[fallthrough]];
14656 case 3:
14657 2076 dir&=3;
14658 2076 misc=0;
14659 [[fallthrough]];
14660 case 0:
14661 10647 wizzrobe_newdir(64);
14662 [[fallthrough]];
14663 default:
14664
2/2
✓ Branch 0 taken 11578 times.
✓ Branch 1 taken 1361 times.
12939 if(!canmove(dir,(zfix)1,spw_door,false))
14665 {
14666
2/2
✓ Branch 0 taken 1295 times.
✓ Branch 1 taken 66 times.
1361 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
14667 {
14668 1295 misc=1;
14669 1295 clk3=16;
14670 1295 }
14671 else
14672 {
14673 66 wizzrobe_newdir(64);
14674 66 misc=0;
14675 66 clk3=32;
14676 }
14677 1361 }
14678 else
14679 {
14680 11578 clk3=32;
14681 }
14682
14683 12939 break;
14684 }
14685
14686
2/2
✓ Branch 0 taken 16254 times.
✓ Branch 1 taken 2006 times.
18260 if(misc<0)
14687 2006 ++misc;
14688 18260 }
14689
14690 458530 --clk3;
14691
14692
3/3
✓ Branch 0 taken 96043 times.
✓ Branch 1 taken 327675 times.
✓ Branch 2 taken 34812 times.
458530 switch(misc)
14693 {
14694 case 1:
14695 case 3:
14696 96043 step=1;
14697 96043 break;
14698
14699 case 2:
14700 34812 step=0;
14701 34812 break;
14702
14703 default:
14704 327675 step=0.5;
14705 327675 break;
14706
14707 }
14708
14709 458530 move(step);
14710
14711 // if(d->misc1 && misc<=0 && clk3==28)
14712
5/6
✓ Branch 0 taken 458530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 327675 times.
✓ Branch 3 taken 130855 times.
✓ Branch 4 taken 316347 times.
✓ Branch 5 taken 11328 times.
458530 if(dmisc1 && misc<=0 && clk3==28)
14713 {
14714
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1448 times.
11328 if(dmisc2 != 1)
14715 {
14716
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
14717 {
14718 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
14719 // sfx(WAV_WAND,pan(int32_t(x)));
14720 1126 wizzrobe_attack_for_real();
14721 1126 fclk=30;
14722 1126 }
14723 9880 }
14724 else
14725 {
14726
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 323 times.
1448 if((zc_oldrand()%500)>=400)
14727 {
14728 323 wizzrobe_attack_for_real();
14729 323 fclk=30;
14730 323 }
14731 }
14732 11328 }
14733
14734
4/4
✓ Branch 0 taken 282550 times.
✓ Branch 1 taken 175980 times.
✓ Branch 2 taken 2168 times.
✓ Branch 3 taken 280382 times.
458530 if(misc==0 && (zc_oldrand()&127)==0)
14735 2168 misc=2;
14736
14737
4/4
✓ Branch 0 taken 36980 times.
✓ Branch 1 taken 421550 times.
✓ Branch 2 taken 35119 times.
✓ Branch 3 taken 1861 times.
458530 if(misc==2 && clk3==4)
14738 1861 fix_coords();
14739
14740
2/4
✓ Branch 0 taken 458530 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 458530 times.
458530 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
14741 {
14742
2/2
✓ Branch 0 taken 417284 times.
✓ Branch 1 taken 41246 times.
458530 if(fclk>0)
14743 {
14744 41246 --fclk;
14745 41246 }
14746 458530 }
14747
14748 494064 }
14749
14750 11202 void eWizzrobe::wizzrobe_newdir(int32_t homing)
14751 {
14752 // Wizzrobes shouldn't move to the edge of the screen;
14753 // if they're already there, they should move toward the center
14754
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11198 times.
11202 if(x<32)
14755 4 dir=right;
14756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11198 times.
11198 else if(x>=224)
14757 dir=left;
14758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11198 times.
11198 else if(y<32)
14759 dir=down;
14760
1/2
✓ Branch 0 taken 11198 times.
✗ Branch 1 not taken.
11198 else if(y>=144)
14761 dir=up;
14762 else
14763 11198 newdir(4,homing,spw_wizzrobe);
14764 11202 }
14765
14766 997386 void eWizzrobe::draw(BITMAP *dest)
14767 {
14768 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
14769
13/14
✓ Branch 0 taken 503916 times.
✓ Branch 1 taken 493470 times.
✓ Branch 2 taken 422836 times.
✓ Branch 3 taken 81080 times.
✓ Branch 4 taken 51740 times.
✓ Branch 5 taken 452176 times.
✓ Branch 6 taken 51056 times.
✓ Branch 7 taken 684 times.
✓ Branch 8 taken 50299 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 48078 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 48078 times.
✗ Branch 13 not taken.
997386 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
14770 48078 return;
14771
14772 949308 int32_t tempint=dummy_int[1];
14773 949308 bool tempbool1=dummy_bool[1];
14774 949308 bool tempbool2=dummy_bool[2];
14775 949308 dummy_int[1]=fclk;
14776 949308 dummy_bool[1]=charging;
14777 949308 dummy_bool[2]=firing;
14778 949308 update_enemy_frame();
14779 949308 dummy_int[1]=tempint;
14780 949308 dummy_bool[1]=tempbool1;
14781 949308 dummy_bool[2]=tempbool2;
14782 949308 enemy::draw(dest);
14783 997386 }
14784
14785 /*********************************/
14786 /********** Bosses ***********/
14787 /*********************************/
14788
14789 270 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14790 270 {
14791 135 fading=fade_flash_die;
14792 //nets+5120;
14793
6/8
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 30 times.
✓ Branch 7 taken 3 times.
135 if(dir==down&&y>=128)
14794 {
14795 3 dir=up;
14796 3 }
14797
14798
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
135 if(dir==right&&x>=208)
14799 {
14800 dir=left;
14801 }
14802 135 SIZEflags = d->SIZEflags;
14803
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
135 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14804 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14805 // al_trace("Enemy txsz:%i\n", txsz);
14806
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
135 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
135 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
135 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14809
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
135 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14810
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14811
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14812 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
135 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14815 {
14816 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14817 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14818 }
14819
14820
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
135 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14821 135 }
14822
14823 91780 bool eDodongo::animate(int32_t index)
14824 {
14825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91780 times.
91780 if(switch_hooked) return enemy::animate(index);
14826
2/2
✓ Branch 0 taken 3114 times.
✓ Branch 1 taken 88666 times.
91780 if(dying)
14827 {
14828 3114 return Dead(index);
14829 }
14830
14831
2/2
✓ Branch 0 taken 88263 times.
✓ Branch 1 taken 403 times.
88666 if(clk==0)
14832 {
14833 403 removearmos(x,y,ffcactivated);
14834 403 }
14835
14836
2/2
✓ Branch 0 taken 8448 times.
✓ Branch 1 taken 80218 times.
88666 if(clk2) // ate a bomb
14837 {
14838
2/2
✓ Branch 0 taken 8360 times.
✓ Branch 1 taken 88 times.
8448 if(--clk2==0)
14839 88 hp-=misc; // store bomb's power in misc
14840 8448 }
14841 else
14842 80218 constant_walk(rate,homing,spw_clipright);
14843
14844 88666 hxsz = (dir<=down) ? 16 : 32;
14845 // hysz = (dir>=left) ? 16 : 32;
14846
14847 88666 return enemy::animate(index);
14848 91780 }
14849
14850 91771 void eDodongo::draw(BITMAP *dest)
14851 {
14852 91771 tile=o_tile;
14853
14854
2/2
✓ Branch 0 taken 2212 times.
✓ Branch 1 taken 89559 times.
91771 if(clk<0)
14855 {
14856 2212 enemy::drawzcboss(dest);
14857 2212 return;
14858 }
14859
14860 89559 update_enemy_frame();
14861 89559 enemy::drawzcboss(dest);
14862
14863
2/2
✓ Branch 0 taken 36564 times.
✓ Branch 1 taken 52995 times.
89559 if(dummy_int[1]!=0) //additional tiles
14864 {
14865 52995 tile+=dummy_int[1]; //second tile is previous tile
14866 52995 xofs-=16; //new xofs change
14867 52995 enemy::drawzcboss(dest);
14868 52995 xofs+=16;
14869 52995 }
14870
14871 91771 }
14872
14873 5941 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
14874 {
14875 5941 int32_t wpnId = w->id;
14876 5941 int32_t power = w->power;
14877 5941 int32_t wpnx = w->x;
14878 5941 int32_t wpny = w->y;
14879
14880
5/12
✓ Branch 0 taken 5941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1675 times.
✓ Branch 5 taken 4266 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1675 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
5941 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
14881 4266 return 0;
14882
14883
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 966 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
1675 switch(wpnId)
14884 {
14885 case wPhantom:
14886 return 0;
14887
14888 case wFire:
14889 case wBait:
14890 case wWhistle:
14891 case wWind:
14892 case wSSparkle:
14893 case wFSparkle:
14894 return 0;
14895
14896 case wLitBomb:
14897 case wLitSBomb:
14898
6/6
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 395 times.
✓ Branch 2 taken 235 times.
✓ Branch 3 taken 364 times.
✓ Branch 4 taken 511 times.
✓ Branch 5 taken 88 times.
599 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
14899 511 return 0;
14900
14901 88 clk2=96;
14902 88 misc=power;
14903
14904
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 3 times.
88 if(wpnId==wLitSBomb)
14905 3 item_set=isSBOMB100;
14906
14907 88 return 1;
14908
14909 case wBomb:
14910 case wSBomb:
14911
6/6
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 577 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 677 times.
✓ Branch 4 taken 349 times.
✓ Branch 5 taken 617 times.
966 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
14912 349 return 0;
14913
14914 617 stunclk=160;
14915 617 misc=wpnId; // store wpnId
14916 617 return 1;
14917
14918 case wSword:
14919
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 63 times.
94 if(stunclk)
14920 {
14921 63 sfx(WAV_EHIT,pan(int32_t(x)));
14922 63 hp=0;
14923 63 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
14924 63 fading=0; // don't flash
14925 63 return 1;
14926 }
14927
14928 [[fallthrough]];
14929 default:
14930 47 sfx(WAV_CHINK,pan(int32_t(x)));
14931 47 }
14932
14933 47 return 1;
14934 5941 }
14935
14936 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14937 4 {
14938 2 fading=fade_flash_die;
14939 //nets+5180;
14940 2 previous_dir=-1;
14941
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
14942 {
14943 dir=up;
14944 }
14945
14946
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
14947 {
14948 dir=left;
14949 }
14950 2 SIZEflags = d->SIZEflags;
14951
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14952 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14953 // al_trace("Enemy txsz:%i\n", txsz);
14954
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14956
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14957
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14958
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14959
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14960 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14961
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14963 {
14964 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14965 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14966 }
14967
14968
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14969 2 }
14970
14971 848 bool eDodongo2::animate(int32_t index)
14972 {
14973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
14974
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
14975 {
14976 36 return Dead(index);
14977 }
14978
14979
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
14980 {
14981 4 removearmos(x,y,ffcactivated);
14982 4 }
14983
14984
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
14985 {
14986
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
14987 2 hp-=misc; // store bomb's power in misc
14988 192 }
14989 else
14990 620 constant_walk(rate,homing,spw_clipbottomright);
14991
14992 812 hxsz = (dir<=down) ? 16 : 32;
14993 812 hysz = (dir>=left) ? 16 : 32;
14994 812 hxofs=(dir>=left)?-8:0;
14995 812 hyofs=(dir<left)?-8:0;
14996
14997 812 return enemy::animate(index);
14998 848 }
14999
15000 848 void eDodongo2::draw(BITMAP *dest)
15001 {
15002
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
15003 {
15004 30 enemy::drawzcboss(dest);
15005 30 return;
15006 }
15007
15008 818 int32_t tempx=xofs;
15009 818 int32_t tempy=yofs;
15010 818 update_enemy_frame();
15011 818 enemy::drawzcboss(dest);
15012 818 tile+=dummy_int[1]; //second tile change
15013 818 xofs+=dummy_int[2]; //new xofs change
15014 818 yofs+=dummy_int[3]; //new yofs change
15015 818 enemy::drawzcboss(dest);
15016 818 xofs=tempx;
15017 818 yofs=tempy;
15018 848 }
15019
15020 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
15021 {
15022 165 int32_t wpnId = w->id;
15023 165 int32_t power = w->power;
15024 165 int32_t wpnx = w->x;
15025 165 int32_t wpny = w->y;
15026
15027
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
15028 145 return 0;
15029
15030
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
15031 {
15032 case wPhantom:
15033 return 0;
15034
15035 case wFire:
15036 case wBait:
15037 case wWhistle:
15038 case wWind:
15039 case wSSparkle:
15040 case wFSparkle:
15041 return 0;
15042
15043 case wLitBomb:
15044 case wLitSBomb:
15045
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
15046 {
15047 case up:
15048 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15049 return 0;
15050
15051 break;
15052
15053 case down:
15054 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15055 return 0;
15056
15057 break;
15058
15059 case left:
15060
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15061 return 0;
15062
15063 2 break;
15064
15065 case right:
15066 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15067 return 0;
15068
15069 break;
15070 }
15071
15072 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
15073 // return 0;
15074 2 clk2=96;
15075 2 misc=power;
15076
15077
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
15078 item_set=isSBOMB100;
15079
15080 2 return 1;
15081
15082 case wBomb:
15083 case wSBomb:
15084
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
15085 {
15086 case up:
15087 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15088 return 0;
15089
15090 break;
15091
15092 case down:
15093 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15094 return 0;
15095
15096 break;
15097
15098 case left:
15099
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15100 return 0;
15101
15102 15 break;
15103
15104 case right:
15105 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15106 return 0;
15107
15108 break;
15109 }
15110
15111 15 stunclk=160;
15112 15 misc=wpnId; // store wpnId
15113 15 return 1;
15114
15115 case wSword:
15116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
15117 {
15118 2 sfx(WAV_EHIT,pan(int32_t(x)));
15119 2 hp=0;
15120 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
15121 2 fading=0; // don't flash
15122 2 return 1;
15123 }
15124
15125 [[fallthrough]];
15126 default:
15127 1 sfx(WAV_CHINK,pan(int32_t(x)));
15128 1 }
15129
15130 1 return 1;
15131 165 }
15132
15133 148 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
15134 148 {
15135 //these are here to bypass compiler warnings about unused arguments
15136
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( !(editorflags & ENEMY_FLAG5) )
15137 {
15138
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 x = dmisc1 ? 64 : 176;
15139
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 y = 64;
15140 74 }
15141 else { x = X; y = Y; }
15142
15143 //nets+5940;
15144
3/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 33 times.
74 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15145 {
15146 41 }
15147 else
15148 {
15149
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 26 times.
33 if(dmisc1)
15150 {
15151 7 flip=1;
15152 7 }
15153 }
15154
15155
3/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
74 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15156 74 clk3=32;
15157 74 clk2=0;
15158 74 clk4=clk;
15159 74 dir=left;
15160 74 SIZEflags = d->SIZEflags;
15161
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15162 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15163 // al_trace("Enemy txsz:%i\n", txsz);
15164
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
74 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15165
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
74 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15166
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
74 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15167
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
74 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15168
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15169
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15170 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15171
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
74 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15173 {
15174 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15175 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15176 }
15177
15178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
74 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15179 74 }
15180
15181 47152 bool eAquamentus::animate(int32_t index)
15182 {
15183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47152 times.
47152 if(switch_hooked) return enemy::animate(index);
15184
2/2
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 45914 times.
47152 if(dying)
15185 1238 return Dead(index);
15186
15187 // fbx=x+((id==eRAQUAM)?4:-4);
15188
2/2
✓ Branch 0 taken 45708 times.
✓ Branch 1 taken 206 times.
45914 if(clk==0)
15189 {
15190 206 removearmos(x,y,ffcactivated);
15191 206 }
15192
15193 45914 fbx=x;
15194
15195 /*
15196 if (get_bit(quest_rules,qr_NEWENEMYTILES)&&id==eLAQUAM)
15197 {
15198 fbx+=16;
15199 }
15200 */
15201
2/2
✓ Branch 0 taken 45620 times.
✓ Branch 1 taken 294 times.
45914 if(--clk3==0)
15202 {
15203 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
15204 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
15205 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
15206 294 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
15207 294 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
15208 294 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
15209 294 sfx(wpnsfx(wpn),pan(int32_t(x)));
15210 294 }
15211
15212
4/4
✓ Branch 0 taken 14065 times.
✓ Branch 1 taken 31849 times.
✓ Branch 2 taken 232 times.
✓ Branch 3 taken 13833 times.
45914 if(clk3<-80 && !(zc_oldrand()&63))
15213 {
15214 232 clk3=32;
15215 232 }
15216
15217
2/2
✓ Branch 0 taken 45180 times.
✓ Branch 1 taken 734 times.
45914 if(!((clk4+1)&63))
15218 {
15219 734 int32_t d2=(zc_oldrand()%3)+1;
15220
15221
2/2
✓ Branch 0 taken 238 times.
✓ Branch 1 taken 496 times.
734 if(d2>=left)
15222 {
15223 496 dir=d2;
15224 496 }
15225
15226
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 392 times.
734 if(dmisc1)
15227 {
15228
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 34 times.
342 if(x<=40)
15229 {
15230 34 dir=right;
15231 34 }
15232
15233
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(x>=104)
15234 {
15235 dir=left;
15236 }
15237 342 }
15238 else
15239 {
15240
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 14 times.
392 if(x<=136)
15241 {
15242 14 dir=right;
15243 14 }
15244
15245
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 17 times.
392 if(x>=200)
15246 {
15247 17 dir=left;
15248 17 }
15249 }
15250 734 }
15251
15252
4/4
✓ Branch 0 taken 44824 times.
✓ Branch 1 taken 1090 times.
✓ Branch 2 taken 39189 times.
✓ Branch 3 taken 5635 times.
45914 if(clk4>=-1 && !((clk4+1)&7))
15253 {
15254
2/2
✓ Branch 0 taken 2991 times.
✓ Branch 1 taken 2644 times.
5635 if(dir==left)
15255 {
15256 2991 x-=1;
15257 2991 }
15258 else
15259 {
15260 2644 x+=1;
15261 }
15262 5635 }
15263
15264 45914 clk4=(clk4+1)%256;
15265
15266 45914 return enemy::animate(index);
15267 47152 }
15268
15269 47563 void eAquamentus::draw(BITMAP *dest)
15270 {
15271
2/2
✓ Branch 0 taken 26079 times.
✓ Branch 1 taken 21484 times.
47563 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15272 {
15273 26079 xofs=(dmisc1?-16:0);
15274
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26079 times.
✓ Branch 2 taken 10724 times.
✓ Branch 3 taken 15355 times.
26079 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
15275
15276
2/2
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 25417 times.
26079 if(dying)
15277 {
15278 662 xofs=0;
15279 662 enemy::draw(dest);
15280 662 }
15281 else
15282 {
15283 25417 drawblock(dest,15);
15284 }
15285 26079 }
15286 else
15287 {
15288 21484 int32_t xblockofs=((dmisc1)?-16:16);
15289 21484 xofs=0;
15290
15291
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
15292 {
15293 1078 enemy::draw(dest);
15294 1078 return;
15295 }
15296
1/2
✓ Branch 0 taken 20406 times.
✗ Branch 1 not taken.
20406 if ( do_animation )
15297 {
15298 // face (0=firing, 2=resting)
15299 20406 tile=o_tile+((clk3>0)?0:2);
15300 20406 enemy::draw(dest);
15301 // tail (
15302 20406 tile=o_tile+((clk&16)?1:3);
15303 20406 xofs=xblockofs;
15304 20406 enemy::draw(dest);
15305 // body
15306 20406 yofs+=16;
15307 20406 xofs=0;
15308 20406 tile=o_tile+((clk&16)?20:22);
15309 20406 enemy::draw(dest);
15310 20406 xofs=xblockofs;
15311 20406 tile=o_tile+((clk&16)?21:23);
15312 20406 enemy::draw(dest);
15313 20406 yofs-=16;
15314 20406 }
15315 else enemy::draw(dest);
15316 }
15317 47563 }
15318
15319 10091 bool eAquamentus::hit(weapon *w)
15320 {
15321
3/6
✓ Branch 0 taken 10091 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10091 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10091 times.
10091 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
15322
15323
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7285 times.
10091 switch(w->id)
15324 {
15325 case wBeam:
15326 case wRefBeam:
15327 case wMagic:
15328 2806 hysz=32;
15329 2806 }
15330
15331
4/4
✓ Branch 0 taken 9966 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 7827 times.
✓ Branch 3 taken 2139 times.
10091 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
15332 10091 hysz=16;
15333 10091 return ret;
15334
15335 10091 }
15336
15337 108 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
15338 108 {
15339
15340
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( !(editorflags & ENEMY_FLAG5) )
15341 {
15342
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 x = 128;
15343
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 y = 48;
15344 54 }
15345 else { x = X; y = Y; }
15346
15347 54 Clk=Clk;
15348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(flags & guy_fadeflicker)
15349 {
15350 clk=0;
15351 superman = 1;
15352 fading=fade_flicker;
15353 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
15354 }
15355
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 36 times.
54 else if(flags & guy_fadeinstant)
15356 {
15357 36 clk=0;
15358 36 }
15359 54 hxofs=-16;
15360 54 hxsz=48;
15361 54 clk4=0;
15362
3/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
54 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15363
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 dir=zc_oldrand()%3+1;
15364 54 SIZEflags = d->SIZEflags;
15365
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15366 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15367 // al_trace("Enemy txsz:%i\n", txsz);
15368
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
15369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
15370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
15371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
15372
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
15373
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
15374 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15375
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
15376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15377 {
15378 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
15379 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15380 }
15381
15382
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
15383
15384 //nets+5340;
15385 54 }
15386
15387 46467 bool eGohma::animate(int32_t index)
15388 {
15389
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46467 times.
46467 if(switch_hooked) return enemy::animate(index);
15390
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 45711 times.
46467 if(dying)
15391 756 return Dead(index);
15392
15393
2/2
✓ Branch 0 taken 45701 times.
✓ Branch 1 taken 10 times.
45711 if(fading)
15394 {
15395
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(++clk4 > 60)
15396 {
15397 10 clk4=0;
15398 10 superman=0;
15399 10 fading=0;
15400 10 clk=0;
15401
15402 10 }
15403 else return enemy::animate(index);
15404 10 }
15405
15406
2/2
✓ Branch 0 taken 45497 times.
✓ Branch 1 taken 214 times.
45711 if(clk==0)
15407 {
15408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 214 times.
214 if (ffcactivated) removearmosffc(ffcactivated-1);
15409 else
15410 {
15411
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 removearmos(zc_max(x-16, zfix(0)),y);
15412 214 did_armos = false;
15413 214 removearmos(x,y);
15414 214 did_armos = false;
15415
1/2
✓ Branch 0 taken 214 times.
✗ Branch 1 not taken.
214 removearmos(zc_min(x+16, zfix(255)),y);
15416 }
15417 214 }
15418
15419
2/2
✓ Branch 0 taken 45438 times.
✓ Branch 1 taken 273 times.
45711 if(clk<0) return enemy::animate(index);
15420
15421 // Movement clk must be separate from animation clk because of the Clock item
15422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45438 times.
45438 if(!watch)
15423 45438 clk4++;
15424
15425
2/2
✓ Branch 0 taken 44754 times.
✓ Branch 1 taken 684 times.
45438 if((clk4&63)==0)
15426 {
15427
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 327 times.
684 if(clk4&64)
15428 357 dir^=1;
15429 else
15430 327 dir=zc_oldrand()%3+1;
15431 684 }
15432
15433
2/2
✓ Branch 0 taken 44705 times.
✓ Branch 1 taken 733 times.
45438 if((clk&63)==3)
15434 {
15435
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 187 times.
733 switch(dmisc1)
15436 {
15437 case 1:
15438 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
15439 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15440 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
15441 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
15442 187 break;
15443
15444 default:
15445
3/4
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 461 times.
546 if(dmisc1 != 1 && dmisc1 != 2)
15446 {
15447 461 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15448 461 sfx(wpnsfx(wpn),pan(int32_t(x)));
15449 461 sfx(wpnsfx(wpn),pan(int32_t(x)));
15450 461 }
15451
15452 546 break;
15453 }
15454 733 }
15455
15456
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40082 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45438 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
15457 {
15458
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
15459 {
15460 183 FireBreath(true);
15461 183 }
15462 1392 }
15463
15464
2/2
✓ Branch 0 taken 22700 times.
✓ Branch 1 taken 22738 times.
45438 if(clk4&1)
15465 22738 move((zfix)1);
15466
15467
2/2
✓ Branch 0 taken 45338 times.
✓ Branch 1 taken 100 times.
45438 if(++clk3>=400)
15468 100 clk3=0;
15469
15470 45438 return enemy::animate(index);
15471 46467 }
15472
15473 46465 void eGohma::draw(BITMAP *dest)
15474 {
15475 46465 tile=o_tile;
15476
15477
4/4
✓ Branch 0 taken 46192 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 756 times.
✓ Branch 3 taken 45436 times.
46465 if(clk<0 || dying)
15478 {
15479 1029 enemy::drawzcboss(dest);
15480 1029 return;
15481 }
15482
15483
2/2
✓ Branch 0 taken 33103 times.
✓ Branch 1 taken 12333 times.
45436 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15484 {
15485 ///if ( do_animation )
15486 //Yuck. Gohma can just not have this capability right now.
15487 // left side
15488 33103 xofs=-16;
15489 33103 flip=0;
15490 // if(clk&16) tile=180;
15491 // else { tile=182; flip=1; }
15492 33103 tile+=(3*((clk&48)>>4));
15493 33103 enemy::drawzcboss(dest);
15494
15495 // right side
15496 33103 xofs=16;
15497 // tile=(180+182)-tile;
15498 33103 tile=o_tile;
15499 33103 tile+=(3*((clk&48)>>4))+2;
15500 33103 enemy::drawzcboss(dest);
15501
15502 // body
15503 33103 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
15504 33103 tile=o_tile;
15505
15506 // tile+=(3*((clk&24)>>3))+2;
15507
2/2
✓ Branch 0 taken 1743 times.
✓ Branch 1 taken 31360 times.
33103 if(clk3<16)
15508 1743 tile+=7;
15509
2/2
✓ Branch 0 taken 9362 times.
✓ Branch 1 taken 21998 times.
31360 else if(clk3<116)
15510 9362 tile+=10;
15511
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
15512 1315 tile+=7;
15513 else
15514 20683 tile+=((clk3-132)&24)?4:1;
15515
15516 33103 enemy::drawzcboss(dest);
15517
15518 33103 }
15519 else
15520 {
15521 // left side
15522 12333 xofs=-16;
15523 12333 flip=0;
15524
15525
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
15526 {
15527 6226 tile+=2;
15528 6226 flip=1;
15529 6226 }
15530
15531 12333 enemy::draw(dest);
15532
15533 // right side
15534 12333 tile=o_tile;
15535 12333 xofs=16;
15536
15537
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
15538
15539 // tile=(180+182)-tile;
15540 12333 enemy::draw(dest);
15541
15542 // body
15543 12333 tile=o_tile;
15544 12333 xofs=0;
15545
15546
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
15547 720 tile+=4;
15548
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
15549 3884 tile+=5;
15550
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
15551 473 tile+=4;
15552 7256 else tile+=((clk3-132)&8)?3:1;
15553
15554 12333 enemy::draw(dest);
15555
15556 }
15557 46465 }
15558
15559 229 int32_t eGohma::takehit(weapon *w, weapon* realweap)
15560 {
15561 229 int32_t wpnId = w->id;
15562 229 int32_t power = w->power;
15563 229 int32_t wpnx = w->x;
15564 229 int32_t wpnDir = w->dir;
15565 229 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
15566
15567
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 108 times.
229 if(def < 0)
15568 {
15569
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
15570 {
15571 41 sfx(WAV_CHINK,pan(int32_t(x)));
15572 41 return 1;
15573 }
15574 67 }
15575
15576 188 return enemy::takehit(w, realweap);
15577 229 }
15578
15579 396 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15580 396 {
15581 198 count_enemy=(id==(id&0xFFF));
15582 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
15583 198 SIZEflags = d->SIZEflags;
15584
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15585 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15586 // al_trace("Enemy txsz:%i\n", txsz);
15587
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15588
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15589
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15590
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15591
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15592
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15593 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15594
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15596 {
15597 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15598 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15599 }
15600
15601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15602 198 }
15603
15604 75067 bool eLilDig::animate(int32_t index)
15605 {
15606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
15607
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
15608 3006 return Dead(index);
15609
15610
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
15611 {
15612 4113 removearmos(x,y,ffcactivated);
15613 4113 }
15614
15615
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
15616 {
15617
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
15618 711 step+=0.25;
15619 23622 }
15620
15621 72061 variable_walk_8(rate,homing,hrate,spw_floater);
15622 72061 return enemy::animate(index);
15623 75067 }
15624
15625 74914 void eLilDig::draw(BITMAP *dest)
15626 {
15627 74914 tile = o_tile;
15628 // tile = 160;
15629 74914 int32_t fdiv = frate/4;
15630
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15631
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15632 74914 efrate:((clk>=(frate>>1))?1:0);
15633
15634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
15635 {
15636
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15637 {
15638
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5035 times.
✓ Branch 8 taken 5312 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
15639 {
15640 case up: //u
15641 5853 flip=0;
15642 5853 break;
15643
15644 case l_up: //d
15645 5465 flip=0;
15646 5465 tile+=4;
15647 5465 break;
15648
15649 case l_down: //l
15650 5245 flip=0;
15651 5245 tile+=8;
15652 5245 break;
15653
15654 case left: //r
15655 5717 flip=0;
15656 5717 tile+=12;
15657 5717 break;
15658
15659 case r_down: //ul
15660 5242 flip=0;
15661 5242 tile+=20;
15662 5242 break;
15663
15664 case down: //ur
15665 4505 flip=0;
15666 4505 tile+=24;
15667 4505 break;
15668
15669 case r_up: //dl
15670 3937 flip=0;
15671 3937 tile+=28;
15672 3937 break;
15673
15674 case right: //dr
15675 5035 flip=0;
15676 5035 tile+=32;
15677 5035 break;
15678 }
15679
15680 46311 tile+=f2;
15681 46311 }
15682 else
15683 {
15684 28603 tile+=(clk>=6)?1:0;
15685 }
15686 74914 }
15687
15688 74914 enemy::draw(dest);
15689 74914 }
15690
15691 104 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15692 104 {
15693 52 superman=1;
15694
15695 52 SIZEflags = d->SIZEflags;
15696
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15697 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15698 // al_trace("Enemy txsz:%i\n", txsz);
15699
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15701 52 else hxsz=32;
15702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15703 52 else hysz=32;
15704
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15705 52 else hzsz=16; // hard to jump.
15706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15707 52 else hxofs=-8;
15708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15709 52 else hyofs=-8;
15710 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15711
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15713 {
15714 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15715 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15716 }
15717
15718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15719
15720
15721 52 }
15722
15723 22457 bool eBigDig::animate(int32_t index)
15724 {
15725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
15727 return Dead(index);
15728
15729
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
15730 {
15731 3194 removearmos(x,y,ffcactivated);
15732 3194 }
15733
15734
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
15735 {
15736 case 0:
15737 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
15738 22369 break;
15739
15740 case 1:
15741 44 ++misc;
15742 44 break;
15743
15744 case 2:
15745
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
15746 {
15747 105 addenemy(x,y,dmisc1+0x1000,-15);
15748 105 }
15749
15750
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
15751 {
15752 16 addenemy(x,y,dmisc2+0x1000,-15);
15753 16 }
15754
15755
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
15756 {
15757 16 addenemy(x,y,dmisc3+0x1000,-15);
15758 16 }
15759
15760
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
15761 {
15762 16 addenemy(x,y,dmisc4+0x1000,-15);
15763 16 }
15764
15765
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
15766 {
15767 1 guycarryingitem = guys.Count()-1;
15768 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
15769 1 itemguy = false;
15770 1 }
15771
15772 44 stop_bgsfx(index);
15773
15774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
15775
15776 44 return true;
15777 }
15778
15779 22413 return enemy::animate(index);
15780 22457 }
15781
15782 22452 void eBigDig::draw(BITMAP *dest)
15783 {
15784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
15785 {
15786 update_enemy_frame();
15787 xofs-=8;
15788 yofs-=8;
15789 drawblock(dest,15);
15790 xofs+=8;
15791 yofs+=8;
15792 return;
15793 }
15794
15795 22452 tile = o_tile;
15796 22452 int32_t fdiv = frate/4;
15797
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15798
15799
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15800 22452 efrate:((clk>=(frate>>1))?1:0);
15801
15802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
15803 {
15804
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15805 {
15806
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
15807 {
15808 case up: //u
15809 1115 flip=0;
15810 1115 break;
15811
15812 case l_up: //d
15813 1221 flip=0;
15814 1221 tile+=8;
15815 1221 break;
15816
15817 case l_down: //l
15818 1344 flip=0;
15819 1344 tile+=40;
15820 1344 break;
15821
15822 case left: //r
15823 1195 flip=0;
15824 1195 tile+=48;
15825 1195 break;
15826
15827 case r_down: //ul
15828 1233 flip=0;
15829 1233 tile+=80;
15830 1233 break;
15831
15832 case down: //ur
15833 1223 flip=0;
15834 1223 tile+=88;
15835
15836 1223 break;
15837
15838 case r_up: //dl
15839 993 flip=0;
15840 993 tile+=120;
15841 993 break;
15842
15843 case right: //dr
15844 1450 flip=0;
15845 1450 tile+=128;
15846 1450 break;
15847 }
15848
15849 10238 tile+=(f2*2);
15850 10238 }
15851 else
15852 {
15853 12214 tile+=(f2)?0:2;
15854 12214 flip=(clk&1)?1:0;
15855 }
15856 22452 }
15857
15858 22452 xofs-=8;
15859 22452 yofs-=8;
15860 22452 drawblock(dest,15);
15861 22452 xofs+=8;
15862 22452 yofs+=8;
15863 22452 }
15864
15865 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
15866 {
15867 740 int32_t wpnId = w->id;
15868
15869
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
15870 44 misc=1;
15871
15872 740 return 0;
15873 }
15874
15875 /*
15876 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15877 {
15878 hxofs=hyofs=8;
15879 hzsz=16; //can't be jumped.
15880 clk2=70;
15881 misc=-1;
15882 mainguy=!getmapflag();
15883 }
15884
15885 bool eGanon::animate(int32_t index)
15886 {
15887 if(switch_hooked) return enemy::animate(index);
15888 if(dying)
15889
15890 return Dead(index);
15891
15892 if(clk==0)
15893 {
15894 removearmos(x,y,ffcactivated);
15895 }
15896
15897 switch(misc)
15898 {
15899 case -1:
15900 misc=0;
15901
15902 case 0:
15903 if(++clk2>72 && !(zc_oldrand()&3))
15904 {
15905 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
15906 sfx(wpnsfx(wpn),pan(int32_t(x)));
15907 clk2=0;
15908 }
15909
15910 Stunclk=0;
15911 constant_walk(rate,homing,spw_none);
15912 break;
15913
15914 case 1:
15915 case 2:
15916 if(--Stunclk<=0)
15917 {
15918 int32_t r=zc_oldrand();
15919
15920 if(r&1)
15921 {
15922 y=96;
15923
15924 if(r&2)
15925 x=160;
15926 else
15927 x=48;
15928
15929 if(tooclose(x,y,48))
15930 x=208-x;
15931 }
15932
15933 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
15934 //{
15935 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15936 // }
15937 // else
15938 // {
15939 loadpalset(csBOSS,pSprite(d->bosspal));
15940 // }
15941 misc=0;
15942 }
15943
15944 break;
15945
15946 case 3:
15947 {
15948 if(hclk>0)
15949 break;
15950
15951 misc=4;
15952 clk=0;
15953 hxofs=1000;
15954 loadpalset(9,pSprite(spPILE));
15955 music_stop();
15956 stop_sfx(WAV_ROAR);
15957
15958 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
15959
15960 sfx(WAV_GANON);
15961 //Ganon's dustpile; fall in sideview. -Z
15962 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
15963 dustpile->linked_parent = eeGANON;
15964 setmapflag();
15965 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
15966 break;
15967 }
15968
15969 case 4:
15970 if(clk>=80)
15971 {
15972 misc=5;
15973
15974 if(getmapflag())
15975 {
15976 game->lvlitems[dlevel]|=liBOSS;
15977 //play_DmapMusic();
15978 playLevelMusic();
15979 return true;
15980 }
15981
15982 sfx(WAV_CLEARED);
15983 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
15984 setmapflag();
15985 }
15986
15987 break;
15988 }
15989
15990 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
15991 //{
15992 //if ( current_item_id(itype_amulet,false) >= 2 )
15993 //{
15994 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15995 //}
15996 //}
15997
15998
15999 return enemy::animate(index);
16000 }
16001
16002
16003 int32_t eGanon::takehit(weapon *w, weapon* realweap)
16004 {
16005 //these are here to bypass compiler warnings about unused arguments
16006 int32_t wpnId = w->id;
16007 int32_t power = w->power;
16008 int32_t enemyHitWeapon = w->parentitem;
16009
16010 switch(misc)
16011 {
16012 case 0:
16013 {
16014 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
16015 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
16016 return 0;
16017
16018 //if we are not using the new defences, just reduce his HP
16019 if (!(editorflags & ENEMY_FLAG14))
16020 {
16021 hp-=power;
16022 if(hp>0)
16023 {
16024 misc=1;
16025 Stunclk=64;
16026 }
16027 else
16028 {
16029 loadpalset(csBOSS,pSprite(spBROWN));
16030 misc=2;
16031 Stunclk=284;
16032 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16033 }
16034
16035 sfx(WAV_EHIT,pan(int32_t(x)));
16036
16037 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16038
16039 return 1;
16040 }
16041 //otherwise, resolve his defence.
16042 else
16043 {
16044 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
16045 if(hp>0)
16046 {
16047 misc=1;
16048 Stunclk=64;
16049 }
16050 else
16051 {
16052 loadpalset(csBOSS,pSprite(spBROWN));
16053 misc=2;
16054 Stunclk=284;
16055 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16056 }
16057
16058 sfx(WAV_EHIT,pan(int32_t(x)));
16059
16060 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16061
16062
16063 return 1;
16064 }
16065 }
16066 case 2:
16067 {
16068 if
16069 (
16070 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
16071 || //or nothing specified, use silver arrows+
16072 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
16073 )
16074 return 0;
16075 {
16076 misc=3;
16077 hclk=81;
16078 loadpalset(9,pSprite(spBROWN));
16079 return 1;
16080 }
16081
16082 }
16083 }
16084
16085 return 0;
16086 }
16087
16088 void eGanon::draw(BITMAP *dest)
16089 {
16090 switch(misc)
16091 {
16092 case 0:
16093 if((clk&3)==3)
16094 tile=(zc_oldrand()%5)*2+o_tile;
16095
16096 if(db!=999)
16097 break;
16098
16099 case 2:
16100 if(Stunclk<64 && (Stunclk&1) )
16101 {
16102 if
16103 (
16104 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16105 ||
16106 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16107 )
16108 {
16109 goto ganon_draw; //draw his weapons if we can see him
16110 }
16111 break;
16112 }
16113
16114 case -1:
16115 tile=o_tile;
16116
16117 //fall through
16118 case 1:
16119 case 3:
16120 ganon_draw:
16121 drawblock(dest,15);
16122 break;
16123
16124 case 4:
16125 draw_guts(dest);
16126 draw_flash(dest);
16127 break;
16128 }
16129
16130 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
16131 {
16132 if
16133 (
16134 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16135 ||
16136 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16137 )
16138 {
16139 draw_guts(dest); //makes his shots visible, but not him
16140 draw_flash(dest);
16141 }
16142 }
16143 }
16144
16145 void eGanon::draw_guts(BITMAP *dest)
16146 {
16147 int32_t c = zc_min(clk>>3,8);
16148 tile = clk<24 ? 74 : 75;
16149 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16150 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16151 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16152 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16153 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16154 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16155 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16156 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16157 }
16158
16159 void eGanon::draw_flash(BITMAP *dest)
16160 {
16161
16162 int32_t c = clk-(clk>>2);
16163 cs = (frame&3)+6;
16164 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16165 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16166 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16167 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16168 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16169 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16170 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16171 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16172 }
16173 */
16174
16175 18 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16176 18 {
16177 9 hxofs=hyofs=8;
16178
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if (editorflags & ENEMY_FLAG3)
16179 {
16180 hxofs = 4;
16181 hyofs = 4;
16182 hxsz = 24;
16183 hysz = 24;
16184 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
16185 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
16186 }
16187 9 hzsz=16; //can't be jumped.
16188 9 clk2=70;
16189 9 misc=-1;
16190
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 mainguy=(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
16191 9 }
16192
16193 14182 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
16194 {
16195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14182 times.
14182 if(dying)
16196
16197 return Dead(index);
16198
16199
2/2
✓ Branch 0 taken 14126 times.
✓ Branch 1 taken 56 times.
14182 if(clk==0)
16200 {
16201 56 removearmos(x,y,ffcactivated);
16202 56 }
16203
16204
6/7
✓ Branch 0 taken 2543 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10328 times.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 656 times.
✓ Branch 5 taken 640 times.
✓ Branch 6 taken 6 times.
14182 switch(misc)
16205 {
16206 case -1:
16207 9 misc=0;
16208 [[fallthrough]];
16209 case 0:
16210
4/4
✓ Branch 0 taken 569 times.
✓ Branch 1 taken 9768 times.
✓ Branch 2 taken 428 times.
✓ Branch 3 taken 141 times.
10337 if(++clk2>72 && !(zc_oldrand()&3))
16211 {
16212 141 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16213 141 sfx(wpnsfx(wpn),pan(int32_t(x)));
16214 141 clk2=0;
16215 141 }
16216
16217 10337 Stunclk=0;
16218 10337 constant_walk(rate,homing,spw_none);
16219 10337 break;
16220
16221 case 1:
16222 case 2:
16223
2/2
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 31 times.
2543 if(--Stunclk<=0)
16224 {
16225 31 int32_t r=zc_oldrand();
16226
16227
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 13 times.
31 if(r&1)
16228 {
16229 13 y=96;
16230
16231
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 8 times.
13 if(r&2)
16232 5 x=160;
16233 else
16234 8 x=48;
16235
16236
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 5 times.
13 if(tooclose(x,y,48))
16237 5 x=208-x;
16238 13 }
16239
16240 31 loadpalset(csBOSS,pSprite(d->bosspal));
16241 31 misc=0;
16242 31 }
16243
16244 2543 break;
16245
16246 case 3:
16247 {
16248
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 8 times.
656 if(hclk>0)
16249 648 break;
16250
16251 8 misc=4;
16252 8 clk=0;
16253 8 hxofs=1000;
16254 8 loadpalset(9,pSprite(spPILE));
16255 8 music_stop();
16256 8 stop_sfx(WAV_ROAR);
16257
16258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
16259
16260 8 sfx(WAV_GANON);
16261 //Ganon's dustpile; fall in sideview. -Z
16262 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
16263 //dustpile->miscellaneous[31] = eeGANON;
16264
6/12
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
8 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16265 8 item *dustpile = NULL;
16266 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
16267 8 dustpile = (item *)items.spr(items.Count() - 1);
16268 8 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
16269 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
16270 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16271 8 break;
16272 }
16273
16274 case 4:
16275
2/2
✓ Branch 0 taken 632 times.
✓ Branch 1 taken 8 times.
640 if(clk>=80)
16276 {
16277 8 misc=5;
16278
16279 //game->lvlitems[dlevel]|=liBOSS;
16280
16281 8 sfx(WAV_CLEARED);
16282 //Add the big TF over the ashes!
16283
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 for(word q = 0; q < items.Count(); q++)
16284 {
16285 16 item *ashes = (item*)items.spr(q);
16286
3/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 8 times.
16 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
16287 {
16288 //Z_scripterrlog("Found correct dustpile!\n");
16289
4/8
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
8 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
16290 8 item *bigtriforce = NULL;
16291 8 bigtriforce = (item *)items.spr(items.Count() - 1);
16292 8 bigtriforce->linked_parent = eeGANON;
16293 8 }
16294 16 }
16295 //setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16296 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
16297 8 }
16298
16299 640 break;
16300 6 case 5: return true;
16301 }
16302
16303 14176 return enemy::animate(index);
16304 14182 }
16305
16306
16307 679 int32_t eGanon::takehit(weapon *w, weapon* realweap)
16308 {
16309 //these are here to bypass compiler warnings about unused arguments
16310 679 int32_t wpnId = w->id;
16311 679 int32_t power = w->power;
16312 679 int32_t enemyHitWeapon = w->parentitem;
16313
16314
3/3
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 88 times.
679 switch(misc)
16315 {
16316 case 0:
16317
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
62 if(wpnId!=wSword)
16318 23 return 0;
16319
16320 39 hp-=power;
16321
16322
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
39 if(hp>0)
16323 {
16324 31 misc=1;
16325 31 Stunclk=64;
16326 31 }
16327 else
16328 {
16329 8 loadpalset(csBOSS,pSprite(spBROWN));
16330 8 misc=2;
16331 8 Stunclk=284;
16332 8 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16333 }
16334
16335 39 sfx(WAV_EHIT,pan(int32_t(x)));
16336
16337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39 times.
39 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16338
16339 39 return 1;
16340
16341 case 2:
16342
4/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
88 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
16343 80 return 0;
16344
16345 8 misc=3;
16346 8 hclk=81;
16347 8 loadpalset(9,pSprite(spBROWN));
16348 8 return 1;
16349 }
16350
16351 529 return 0;
16352 679 }
16353
16354 15928 void eGanon::draw(BITMAP *dest)
16355 {
16356
6/6
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 559 times.
✓ Branch 3 taken 1755 times.
✓ Branch 4 taken 10328 times.
✓ Branch 5 taken 640 times.
15928 switch(misc)
16357 {
16358 case 0:
16359
2/2
✓ Branch 0 taken 7747 times.
✓ Branch 1 taken 2581 times.
10328 if((clk&3)==3)
16360 2581 tile=(zc_oldrand()%5)*2+o_tile;
16361
16362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10328 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
16363 {
16364
16365 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16366 {
16367 int odraw = drawstyle;
16368 drawstyle = 2;
16369 drawblock(dest,15);
16370 drawstyle = odraw;
16371 }
16372 else
16373 {
16374 drawblock(dest,15);
16375 }
16376 break;
16377
16378 }
16379
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10328 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10328 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
16380 {
16381 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16382 {
16383 int odraw = drawstyle;
16384 drawstyle = 2;
16385 drawblock(dest,15);
16386 drawstyle = odraw;
16387 }
16388 else
16389 {
16390 drawblock(dest,15);
16391 }
16392 break;
16393 }
16394
1/2
✓ Branch 0 taken 10328 times.
✗ Branch 1 not taken.
10328 if(db!=999)
16395 10328 break;
16396 [[fallthrough]];
16397 case 2:
16398
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
559 if(Stunclk<64 && (Stunclk&1))
16399 break;
16400 [[fallthrough]];
16401 case -1:
16402 2314 tile=o_tile;
16403
16404 [[fallthrough]];
16405 case 1:
16406 case 3:
16407 4954 drawblock(dest,15);
16408 4954 break;
16409
16410 case 4:
16411 640 draw_guts(dest);
16412 640 draw_flash(dest);
16413 640 break;
16414 }
16415 15928 }
16416
16417 640 void eGanon::draw_guts(BITMAP *dest)
16418 {
16419
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 136 times.
640 int32_t c = zc_min(clk>>3,8);
16420 640 tile = clk<24 ? 74 : 75;
16421 640 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16422 640 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16423 640 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16424 640 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16425 640 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16426 640 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16427 640 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16428 640 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16429 640 }
16430
16431 640 void eGanon::draw_flash(BITMAP *dest)
16432 {
16433
16434 640 int32_t c = clk-(clk>>2);
16435 640 cs = (frame&3)+6;
16436 640 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16437 640 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16438 640 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16439 640 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16440 640 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16441 640 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16442 640 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16443 640 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16444 640 }
16445
16446 7 void getBigTri(int32_t id2)
16447 {
16448 /*
16449 *************************
16450 * BIG TRIFORCE SEQUENCE *
16451 *************************
16452 0 BIGTRI out, WHITE flash in
16453 4 WHITE flash out, PILE cset white
16454 8 WHITE in
16455 ...
16456 188 WHITE out
16457 191 PILE cset red
16458 200 top SHUTTER opens
16459 209 bottom SHUTTER opens
16460 */
16461 7 sfx(itemsbuf[id2].playsound);
16462 7 guys.clear();
16463
16464
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
16465 {
16466 game->lvlitems[dlevel]|=liTRIFORCE;
16467 }
16468
16469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16470
16471 7 draw_screen(tmpscr);
16472
16473
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1344 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1344 times.
1351 for(int32_t f=0; f<24*8 && !Quit; f++)
16474 {
16475
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 7 times.
1344 if(f==4)
16476 {
16477
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 7 times.
112 for(int32_t i=1; i<16; i++)
16478 {
16479 105 RAMpal[CSET(9)+i]=_RGB(63,63,63);
16480 105 }
16481 7 }
16482
16483
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==0)
16484 {
16485
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t cs=2; cs<5; cs++)
16486 {
16487
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 504 times.
8064 for(int32_t i=1; i<16; i++)
16488 {
16489 7560 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
16490 7560 }
16491 504 }
16492
16493 168 refreshpal=true;
16494 168 }
16495
16496
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 168 times.
1344 if((f&7)==4)
16497 {
16498
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
16499 else loadlvlpal(0xB);
16500 168 }
16501
16502
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 7 times.
1344 if(f==191)
16503 {
16504 7 loadpalset(9,pSprite(spPILE));
16505 7 }
16506
16507 1344 advanceframe(true);
16508 1344 }
16509
16510 //play_DmapMusic();
16511 7 playLevelMusic();
16512
16513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
16514 {
16515 Hero.dowarp(1,0); //side warp
16516 }
16517 7 }
16518
16519 /**********************************/
16520 /*** Multiple-Segment Enemies ***/
16521 /**********************************/
16522
16523
16524 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
16525 170 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16526 170 {
16527
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 if( !(editorflags & ENEMY_FLAG5) )
16528 {
16529
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 x=128;
16530
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 y=48;
16531 85 }
16532 //else { x = X; y = Y; }
16533
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 dir=(zc_oldrand()&7)+8;
16534 85 superman=1;
16535 85 fading=fade_invisible;
16536 85 hxofs=1000;
16537 85 segcnt=clk;
16538 85 segid=Id|0x1000;
16539 85 clk=0;
16540
1/2
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
85 id=guys.Count();
16541
3/6
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 85 times.
✗ Branch 5 not taken.
85 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16542 85 tile=o_tile;
16543 85 hitdir = -1;
16544 85 stickclk = 0;
16545
16546 /*
16547 if (get_bit(quest_rules,qr_NEWENEMYTILES))
16548 {
16549 tile=nets+1220;
16550 }
16551 else
16552 {
16553 tile=57;
16554 }
16555 */
16556 85 }
16557
16558 79409 bool eMoldorm::animate(int32_t index)
16559 {
16560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79409 times.
79409 if(switch_hooked) return enemy::animate(index);
16561 79409 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
16562
2/2
✓ Branch 0 taken 61065 times.
✓ Branch 1 taken 18344 times.
79409 if ( y > (max_y) )
16563 {
16564 18344 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
16565 //Z_scripterrlog("Stickclk is %d\n", stickclk);
16566 18344 }
16567
2/2
✓ Branch 0 taken 79034 times.
✓ Branch 1 taken 375 times.
79409 if ( stickclk > 45 )
16568 {
16569 375 stickclk = 0;
16570 375 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
16571 375 }
16572
16573
16574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79409 times.
79409 if(clk==0)
16575 {
16576 79409 removearmos(x,y,ffcactivated);
16577 79409 }
16578
16579
2/2
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 78326 times.
79409 if(clk2)
16580 {
16581
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 57 times.
1083 if(--clk2 == 0)
16582 {
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(flags&guy_neverret)
16584 57 never_return(index);
16585
16586
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
16587 57 leave_item();
16588
16589 57 stop_bgsfx(index);
16590 57 return true;
16591 }
16592 1026 }
16593 else
16594 {
16595
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if(stunclk>0)
16596 stunclk=0;
16597 78326 constant_walk_8_old(rate,homing,spw_floater);
16598
16599
16600 78326 misc=dir;
16601
16602 // If any higher-numbered segments were killed, segcnt can be too high,
16603 // leading to a crash
16604
1/2
✓ Branch 0 taken 78326 times.
✗ Branch 1 not taken.
78326 if(index+segcnt>=guys.Count())
16605 segcnt=guys.Count()-index-1;
16606
16607
2/2
✓ Branch 0 taken 78326 times.
✓ Branch 1 taken 429954 times.
508280 for(int32_t i=index+1; i<index+segcnt+1; i++)
16608 {
16609 429954 enemy* segment=((enemy*)guys.spr(i));
16610
16611 // More validation - if segcnt was wrong, this may not
16612 // actually be a Moldorm segment
16613
1/2
✓ Branch 0 taken 429954 times.
✗ Branch 1 not taken.
429954 if(segment->id!=segid)
16614 {
16615 segcnt=i-index-1;
16616 break;
16617 }
16618
16619
2/2
✓ Branch 0 taken 351548 times.
✓ Branch 1 taken 78406 times.
429954 if(i==index+1)
16620 {
16621 78406 x=segment->x;
16622 78406 y=segment->y;
16623 78406 }
16624
16625 429954 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
16626 //Script your own blasted segmented bosses!! -Z
16627 429954 segment->parent_script_UID = this->script_UID;
16628
4/4
✓ Branch 0 taken 78326 times.
✓ Branch 1 taken 351628 times.
✓ Branch 2 taken 11070 times.
✓ Branch 3 taken 67256 times.
429954 if((i==index+segcnt)&&(i!=index+1)) //tail
16629 {
16630 67256 segment->dummy_int[1]=2;
16631 67256 }
16632 else
16633 {
16634 362698 segment->dummy_int[1]=1;
16635 }
16636
16637
2/2
✓ Branch 0 taken 351548 times.
✓ Branch 1 taken 78406 times.
429954 if(i==index+1) //head
16638 {
16639 78406 segment->dummy_int[1]=0;
16640 78406 }
16641
16642
2/2
✓ Branch 0 taken 429599 times.
✓ Branch 1 taken 355 times.
429954 if(segment->hp <= 0)
16643 {
16644 355 int32_t offset=1;
16645
16646
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 577 times.
932 for(int32_t j=i; j<index+segcnt; j++)
16647 {
16648 // Triple-check
16649
1/2
✓ Branch 0 taken 577 times.
✗ Branch 1 not taken.
577 if(((enemy*)guys.spr(j+1))->id!=segid)
16650 {
16651 segcnt=j-index+1; // Add 1 because of --segcnt below
16652 break;
16653 }
16654 577 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16655 577 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16656 577 }
16657
16658 355 segment->hclk=33;
16659 355 --segcnt;
16660 355 --i; // Recheck the same index in case multiple segments died at once
16661 355 }
16662 429954 }
16663
16664
2/2
✓ Branch 0 taken 78269 times.
✓ Branch 1 taken 57 times.
78326 if(segcnt==0)
16665 {
16666 57 clk2=19;
16667
16668 57 x=guys.spr(index+1)->x;
16669 57 y=guys.spr(index+1)->y;
16670 57 }
16671 }
16672
16673 79352 return false;
16674 79409 }
16675
16676 970 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16677 970 {
16678
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 if( !(editorflags & ENEMY_FLAG5) )
16679 {
16680
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 x=128;
16681
1/2
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
485 y=48;
16682 485 }
16683
16684
3/6
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 485 times.
✗ Branch 5 not taken.
485 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16685 485 hyofs=4;
16686 485 hxsz=hysz=8;
16687 485 hxofs=1000;
16688 485 mainguy=count_enemy=false;
16689 485 parentclk = 0;
16690 485 bgsfx=-1;
16691 485 flags&=~guy_neverret;
16692 //deadsfx = WAV_EDEAD;
16693 485 isCore = false;
16694 485 }
16695
16696 436344 bool esMoldorm::animate(int32_t index)
16697 {
16698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436344 times.
436344 if(switch_hooked) return enemy::animate(index);
16699 // Shouldn't be possible, but better to be sure
16700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436344 times.
436344 if(index==0)
16701 dying=true;
16702
16703
2/2
✓ Branch 0 taken 6390 times.
✓ Branch 1 taken 429954 times.
436344 if(dying)
16704 {
16705
1/2
✓ Branch 0 taken 6390 times.
✗ Branch 1 not taken.
6390 if(!dmisc2)
16706 6390 item_set=0;
16707
16708 6390 return Dead(index);
16709 }
16710
16711
2/2
✓ Branch 0 taken 20598 times.
✓ Branch 1 taken 409356 times.
429954 if(clk>=0)
16712 {
16713 409356 hxofs=4;
16714 409356 step=((enemy*)guys.spr(index-1))->step;
16715
16716
2/2
✓ Branch 0 taken 31229 times.
✓ Branch 1 taken 378127 times.
409356 if(parentclk == 0)
16717 {
16718 31229 misc=dir;
16719 31229 dir=((enemy*)guys.spr(index-1))->misc;
16720 //do alignment, as in parent's animation :-/ -DD
16721 31229 x.doFloor();
16722 31229 y.doFloor();
16723 31229 }
16724
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409356 times.
409356 if(step)
16726 409356 parentclk=(parentclk+1)%((int32_t)(8.0/step));
16727
16728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409356 times.
409356 if(!watch)
16729 {
16730 409356 sprite::move(step);
16731 409356 }
16732 409356 }
16733
16734 429954 return enemy::animate(index);
16735 436344 }
16736
16737 1645 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
16738 {
16739
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 147 times.
1645 if(enemy::takehit(w,realweap))
16740 1498 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
16741
16742 147 return 0;
16743 1645 }
16744
16745 438294 void esMoldorm::draw(BITMAP *dest)
16746 {
16747 438294 tile=o_tile;
16748 438294 int32_t fdiv = frate/4;
16749
1/2
✓ Branch 0 taken 438294 times.
✗ Branch 1 not taken.
438294 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
16750
16751
2/2
✓ Branch 0 taken 361156 times.
✓ Branch 1 taken 77138 times.
438294 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
16752 438294 efrate:((clk>=(frate>>1))?1:0);
16753
16754
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 361156 times.
438294 if(get_bit(quest_rules,qr_NEWENEMYTILES))
16755 {
16756 361156 tile+=dummy_int[1]*40;
16757
16758
2/2
✓ Branch 0 taken 16310 times.
✓ Branch 1 taken 344846 times.
361156 if(dir<8)
16759 {
16760 16310 flip=0;
16761
2/2
✓ Branch 0 taken 12412 times.
✓ Branch 1 taken 3898 times.
16310 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
16762
16763
1/2
✓ Branch 0 taken 16310 times.
✗ Branch 1 not taken.
16310 if(dir>3) // Skip to the next row for diagonals
16764 tile+=4;
16765 16310 }
16766 else
16767 {
16768
8/9
✓ Branch 0 taken 37639 times.
✓ Branch 1 taken 47584 times.
✓ Branch 2 taken 38450 times.
✓ Branch 3 taken 47147 times.
✓ Branch 4 taken 39397 times.
✓ Branch 5 taken 38189 times.
✓ Branch 6 taken 46292 times.
✓ Branch 7 taken 50148 times.
✗ Branch 8 not taken.
344846 switch(dir-8) //directions get screwed up after 8. *shrug*
16769 {
16770 case up: //u
16771 37639 flip=0;
16772 37639 break;
16773
16774 case l_up: //d
16775 47584 flip=0;
16776 47584 tile+=4;
16777 47584 break;
16778
16779 case l_down: //l
16780 38450 flip=0;
16781 38450 tile+=8;
16782 38450 break;
16783
16784 case left: //r
16785 47147 flip=0;
16786 47147 tile+=12;
16787 47147 break;
16788
16789 case r_down: //ul
16790 39397 flip=0;
16791 39397 tile+=20;
16792 39397 break;
16793
16794 case down: //ur
16795 38189 flip=0;
16796 38189 tile+=24;
16797 38189 break;
16798
16799 case r_up: //dl
16800 46292 flip=0;
16801 46292 tile+=28;
16802 46292 break;
16803
16804 case right: //dr
16805 50148 flip=0;
16806 50148 tile+=32;
16807 50148 break;
16808 }
16809 }
16810
16811 361156 tile+=f2;
16812 361156 }
16813
16814
2/2
✓ Branch 0 taken 20652 times.
✓ Branch 1 taken 417642 times.
438294 if(clk>=0)
16815 417642 enemy::draw(dest);
16816 438294 }
16817
16818 478 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16819 478 {
16820
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
16821 {
16822
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
16823
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
16824 239 }
16825 //else { x = X; y = Y; }
16826 //zprint2("lanmola index is %d\n", index);
16827 //byte legaldirs = 0;
16828 239 int32_t incr = 16;
16829 //int32_t possiiblepos = 0;
16830 //int32_t positions[8] = {0};
16831
16832 //Don't spawn in pits.
16833
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
16834 {
16835 //zprint2("Can't spawn here.\n");
16836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
16837 {
16838 //move if we spawn over a pit
16839 //check each direction
16840
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16841 {
16842 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16843
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
16844 }
16845
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16846 {
16847 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16848
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
16849 }
16850
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16851 {
16852 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16853
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
16854 }
16855
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16856 {
16857 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16858 x+=incr; y-=incr; break;
16859 }
16860
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16861 {
16862 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16863 y -= incr; break;
16864 }
16865
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16866 {
16867 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16868 y+=incr; break;
16869 }
16870
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16871 {
16872 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16873
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
16874 }
16875
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16876 {
16877 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16878 x+=incr; y+=incr; break;
16879 }
16880 34 else continue;
16881
16882 }
16883
16884 90 }
16885
16886 239 dir=up;
16887 239 superman=1;
16888 239 fading=fade_invisible;
16889 239 hxofs=1000;
16890 239 segcnt=clk;
16891 239 clk=0;
16892 //set up move history
16893
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
16894
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
16895 239 }
16896
16897 134485 bool eLanmola::animate(int32_t index)
16898 {
16899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
16900
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
16901 {
16902 22424 removearmos(x,y,ffcactivated);
16903 22424 }
16904
16905
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
16906 {
16907
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
16908 {
16909
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
16910 78 leave_item();
16911
16912 98 stop_bgsfx(index);
16913 98 return true;
16914 }
16915
16916 1764 return false;
16917 }
16918
16919
16920 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
16921 //the direction AND x,y position of the lanmola to vary in uncertain ways.
16922 //I've added a complete movement history to this enemy to compensate -DD
16923 132623 constant_walk(rate,homing,spw_none);
16924 132623 prevState.pop_front();
16925 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
16926
16927 // This could cause a crash with Moldorms. I didn't see the same problem
16928 // with Lanmolas, but it looks like it ought to be possible, so here's
16929 // the same solution. - Saf
16930
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
16931 segcnt=guys.Count()-index-1;
16932
16933
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
16934 {
16935 599039 enemy* segment=((enemy*)guys.spr(i));
16936
16937 // More validation in case segcnt is wrong
16938
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
16939 {
16940 segcnt=i-index-1;
16941 break;
16942 }
16943
16944 599039 segment->o_tile=o_tile;
16945 599039 segment->parent_script_UID = this->script_UID;
16946
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
16947 {
16948 113109 segment->dummy_int[1]=1; //tail
16949 113109 }
16950 else
16951 {
16952 485930 segment->dummy_int[1]=0;
16953 }
16954
16955
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
16956 {
16957
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
16958 {
16959 // Triple-check
16960
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
16961 {
16962 segcnt=j-index+1; // Add 1 because of --segcnt below
16963 break;
16964 }
16965 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16966 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16967 977 }
16968
16969 572 ((enemy*)guys.spr(i))->hclk=33;
16970 572 --segcnt;
16971 572 --i; // Recheck the same index in case multiple segments died at once
16972 572 }
16973 599039 }
16974
16975
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
16976 {
16977 98 clk2=19;
16978 98 x=guys.spr(index+1)->x;
16979 98 y=guys.spr(index+1)->y;
16980 98 setmapflag(mTMPNORET);
16981 98 }
16982
16983 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
16984 //which is... disastrous.
16985 132623 hp = 1;
16986 132623 return enemy::animate(index);
16987 134485 }
16988
16989 2500 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16990 2500 {
16991
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
16992 {
16993
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
16994
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
16995 1250 }
16996 1250 int32_t incr = 16;
16997 //Don't spawn in pits.
16998
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
16999 {
17000 //zprint2("Can't spawn here.\n");
17001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
17002 {
17003 //move if we spawn over a pit
17004 //check each direction
17005
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
17006 {
17007 //zprint2("Spawn adjustment: -x (%d)\n", incr);
17008
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
17009 }
17010
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
17011 {
17012 //zprint2("Spawn adjustment: +x (%d)\n", incr);
17013
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
17014 }
17015
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
17016 {
17017 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
17018
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
17019 }
17020
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
17021 {
17022 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
17023 x+=incr; y-=incr; break;
17024 }
17025
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
17026 {
17027 //zprint2("Spawn adjustment: -y (%d)\n", incr);
17028 y -= incr; break;
17029 }
17030
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
17031 {
17032 //zprint2("Spawn adjustment: +y (%d)\n", incr);
17033 y+=incr; break;
17034 }
17035
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
17036 {
17037 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
17038
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
17039 }
17040
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
17041 {
17042 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
17043 x+=incr; y+=incr; break;
17044 }
17045 170 else continue;
17046
17047 }
17048
17049 450 }
17050
17051 1250 hxofs=1000;
17052 1250 hxsz=8;
17053 1250 mainguy=false;
17054 1250 count_enemy=(id<0x2000)?true:false;
17055
17056 //set up move history
17057
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
17058
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
17059
17060 1250 bgsfx = -1;
17061 1250 isCore = false;
17062 1250 flags&=~guy_neverret;
17063 1250 }
17064
17065 609335 bool esLanmola::animate(int32_t index)
17066 {
17067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
17068 // Shouldn't be possible, but who knows
17069
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
17070 dying=true;
17071
17072
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
17073 {
17074 10296 xofs=0;
17075
17076
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
17077 8496 item_set=0;
17078
17079 10296 return Dead(index);
17080 }
17081
17082
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
17083 {
17084 579729 hxofs=4;
17085
17086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
17087 {
17088 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
17089 579729 prevState.pop_front();
17090 579729 prevState.push_back(newstate);
17091 579729 x = newstate.first.first;
17092 579729 y = newstate.first.second;
17093 579729 dir = newstate.second;
17094 579729 }
17095 579729 }
17096
17097 599039 return enemy::animate(index);
17098 609335 }
17099
17100 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
17101 {
17102
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
17103 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
17104
17105 131 return 0;
17106 1513 }
17107
17108 610611 void esLanmola::draw(BITMAP *dest)
17109 {
17110 610611 tile=o_tile;
17111 610611 int32_t fdiv = frate/4;
17112
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17113
17114
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17115 610611 efrate:((clk>=(frate>>1))?1:0);
17116
17117
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17118 {
17119
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
17120 {
17121 269264 tile+=20;
17122
17123
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
17124 {
17125 59482 tile+=20;
17126 59482 }
17127 269264 }
17128
17129
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
17130 {
17131 case up:
17132 70158 flip=0;
17133 70158 break;
17134
17135 case down:
17136 71956 flip=0;
17137 71956 tile+=4;
17138 71956 break;
17139
17140 case left:
17141 93557 flip=0;
17142 93557 tile+=8;
17143 93557 break;
17144
17145 case right:
17146 101862 flip=0;
17147 101862 tile+=12;
17148 101862 break;
17149 }
17150
17151 337533 tile+=f2;
17152 337533 }
17153 else
17154 {
17155
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
17156 {
17157 206447 tile+=1;
17158 206447 }
17159 }
17160
17161
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
17162 591301 enemy::draw(dest);
17163 610611 }
17164
17165 116 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
17166 116 {
17167 //these are here to bypass compiler warnings about unused arguments
17168 58 Clk=Clk;
17169 58 superman=1;
17170
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 dir=(zc_oldrand()&7)+8;
17171 58 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
17172
17173
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<armcnt; i++)
17174 264 arm[i]=i;
17175
17176 58 fading=fade_blue_poof;
17177 //nets+4680;
17178 58 adjusted=false;
17179 58 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
17180
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17181 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17182 // al_trace("Enemy txsz:%i\n", txsz);
17183
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17184
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17186
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17187
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17188
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17189 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17190
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17192 {
17193 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17194 }
17195
17196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17197 58 }
17198
17199 30211 bool eManhandla::animate(int32_t index)
17200 {
17201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30211 times.
30211 if(switch_hooked) return enemy::animate(index);
17202
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 29455 times.
30211 if(dying)
17203 756 return Dead(index);
17204
17205
2/2
✓ Branch 0 taken 28252 times.
✓ Branch 1 taken 1203 times.
29455 if(clk==0)
17206 {
17207 1203 removearmos(x,y,ffcactivated);
17208 1203 }
17209
17210
17211 // check arm status, move dead ones to end of group
17212
2/2
✓ Branch 0 taken 92084 times.
✓ Branch 1 taken 29455 times.
121539 for(int32_t i=0; i<armcnt; i++)
17213 {
17214 92084 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
17215
3/4
✓ Branch 0 taken 92084 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 91884 times.
92084 if(!cur_arm || cur_arm->dying)
17216 {
17217
2/2
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 200 times.
446 for(int32_t j=i; j<armcnt-1; j++)
17218 {
17219 246 zc_swap(arm[j],arm[j+1]);
17220 246 guys.swap(index+j+1,index+j+2);
17221 246 }
17222
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 32 times.
200 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
17223 {
17224 32 leave_item();
17225 32 }
17226 200 --armcnt;
17227 200 --i;
17228 200 continue;
17229 }
17230
2/2
✓ Branch 0 taken 91620 times.
✓ Branch 1 taken 264 times.
91884 if(!adjusted)
17231 {
17232
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 64 times.
264 if(!dmisc2)
17233 {
17234 200 cur_arm->o_tile=o_tile+40;
17235 200 cur_arm->parent_script_UID = this->script_UID;
17236 200 }
17237 else
17238 {
17239 64 cur_arm->o_tile=o_tile+160;
17240 64 cur_arm->parent_script_UID = this->script_UID;
17241 }
17242 264 }
17243 91884 }
17244
17245 29455 adjusted=true;
17246
17247 // move or die
17248
2/2
✓ Branch 0 taken 29413 times.
✓ Branch 1 taken 42 times.
29455 if(armcnt==0)
17249 42 hp=0;
17250 else
17251 {
17252 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
17253
1/2
✓ Branch 0 taken 29413 times.
✗ Branch 1 not taken.
29413 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
17254 29413 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
17255
17256
2/2
✓ Branch 0 taken 26532 times.
✓ Branch 1 taken 2881 times.
29413 if(!dmisc2)
17257 {
17258
2/2
✓ Branch 0 taken 77897 times.
✓ Branch 1 taken 26532 times.
104429 for(int32_t i=0; i<armcnt; i++)
17259 {
17260
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18618 times.
✓ Branch 2 taken 20692 times.
✓ Branch 3 taken 19238 times.
✓ Branch 4 taken 19349 times.
77897 switch(arm[i])
17261 {
17262 case 0:
17263 18618 dy1=-24;
17264 18618 break;
17265
17266 case 1:
17267 20692 dy2=31;
17268 20692 break;
17269
17270 case 2:
17271 19238 dx1=-16;
17272 19238 break;
17273
17274 case 3:
17275 19349 dx2=31;
17276 19349 break;
17277 }
17278 77897 }
17279 26532 }
17280 else
17281 {
17282 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
17283
17284
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
17285 {
17286
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
17287 {
17288 case 0:
17289 4279 dy1=-32;
17290 4279 break;
17291
17292 case 1:
17293 3184 dy2=39;
17294 3184 break;
17295
17296 case 2:
17297 2549 dx1=-24;
17298 2549 break;
17299
17300 case 3:
17301 3975 dx2=39;
17302 3975 break;
17303 }
17304 13987 }
17305 }
17306
17307 29413 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
17308
17309
2/2
✓ Branch 0 taken 91884 times.
✓ Branch 1 taken 29413 times.
121297 for(int32_t i=0; i<armcnt; i++)
17310 {
17311 91884 zfix dx=(zfix)0,dy=(zfix)0;
17312
17313
2/2
✓ Branch 0 taken 77897 times.
✓ Branch 1 taken 13987 times.
91884 if(!dmisc2)
17314 {
17315
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18618 times.
✓ Branch 2 taken 20692 times.
✓ Branch 3 taken 19238 times.
✓ Branch 4 taken 19349 times.
77897 switch(arm[i])
17316 {
17317 case 0:
17318 18618 dy=-16;
17319 18618 break;
17320
17321 case 1:
17322 20692 dy=16;
17323 20692 break;
17324
17325 case 2:
17326 19238 dx=-16;
17327 19238 break;
17328
17329 case 3:
17330 19349 dx=16;
17331 19349 break;
17332 }
17333 77897 }
17334 else
17335 {
17336
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
17337 {
17338 case 0:
17339 1680 dy=-24;
17340 1680 dx=-8;
17341 1680 break;
17342
17343 case 1:
17344 1789 dy=24;
17345 1789 dx=8;
17346 1789 break;
17347
17348 case 2:
17349 1292 dx=-24;
17350 1292 dy=8;
17351 1292 break;
17352
17353 case 3:
17354 2015 dx=24;
17355 2015 dy=-8;
17356 2015 break;
17357
17358 case 4:
17359 2599 dy=-24;
17360 2599 dx=8;
17361 2599 break;
17362
17363 case 5:
17364 1395 dy=24;
17365 1395 dx=-8;
17366 1395 break;
17367
17368 case 6:
17369 1257 dx=-24;
17370 1257 dy=-8;
17371 1257 break;
17372
17373 case 7:
17374 1960 dx=24;
17375 1960 dy=8;
17376 1960 break;
17377 }
17378 }
17379
17380 91884 guys.spr(index+i+1)->x = x+dx;
17381 91884 guys.spr(index+i+1)->y = y+dy;
17382 91884 }
17383 }
17384
17385 29455 return enemy::animate(index);
17386 30211 }
17387
17388
17389 1300 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
17390 {
17391 1300 int32_t wpnId = w->id;
17392
17393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1300 times.
1300 if(dying)
17394 return 0;
17395
17396
3/4
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 433 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1300 switch(wpnId)
17397 {
17398 case wBomb:
17399 case wSBomb:
17400 case wSword:
17401 case wHammer:
17402 case wWand:
17403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 433 times.
433 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17404
17405 case wLitBomb:
17406 case wLitSBomb:
17407 case wBait:
17408 case wWhistle:
17409 case wFire:
17410 case wWind:
17411 case wSSparkle:
17412 case wFSparkle:
17413 case wPhantom:
17414 1283 return 0;
17415
17416 case wHookshot:
17417 case wBrang:
17418 sfx(WAV_CHINK,pan(int32_t(x)));
17419 break;
17420
17421 default:
17422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17423 else sfx(WAV_CHINK,pan(int32_t(x)));
17424
17425 17 }
17426
17427 17 return 1;
17428 1300 }
17429
17430 30209 void eManhandla::draw(BITMAP *dest)
17431 {
17432 30209 tile=o_tile;
17433 30209 int32_t fdiv = frate/4;
17434
1/2
✓ Branch 0 taken 30209 times.
✗ Branch 1 not taken.
30209 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17435
17436
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 8959 times.
30209 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17437 30209 efrate:((clk>=(frate>>1))?1:0);
17438
17439
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 8959 times.
30209 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17440 {
17441
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 18732 times.
21250 if(!dmisc2)
17442 {
17443
8/9
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 2084 times.
✓ Branch 2 taken 2751 times.
✓ Branch 3 taken 2878 times.
✓ Branch 4 taken 1783 times.
✓ Branch 5 taken 1846 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 3061 times.
✗ Branch 8 not taken.
18732 switch(dir-8) //directions get screwed up after 8. *shrug*
17444 {
17445 case up: //u
17446 2400 flip=0;
17447 2400 break;
17448
17449 case l_up: //d
17450 2084 flip=0;
17451 2084 tile+=4;
17452 2084 break;
17453
17454 case l_down: //l
17455 2751 flip=0;
17456 2751 tile+=8;
17457 2751 break;
17458
17459 case left: //r
17460 2878 flip=0;
17461 2878 tile+=12;
17462 2878 break;
17463
17464 case r_down: //ul
17465 1783 flip=0;
17466 1783 tile+=20;
17467 1783 break;
17468
17469 case down: //ur
17470 1846 flip=0;
17471 1846 tile+=24;
17472 1846 break;
17473
17474 case r_up: //dl
17475 1929 flip=0;
17476 1929 tile+=28;
17477 1929 break;
17478
17479 case right: //dr
17480 3061 flip=0;
17481 3061 tile+=32;
17482 3061 break;
17483 }
17484
17485 18732 tile+=f2;
17486 18732 enemy::draw(dest);
17487 18732 } //manhandla 2, big body
17488 else
17489 {
17490
17491
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
17492 {
17493 case up: //u
17494 357 flip=0;
17495 357 break;
17496
17497 case l_up: //d
17498 483 flip=0;
17499 483 tile+=8;
17500 483 break;
17501
17502 case l_down: //l
17503 500 flip=0;
17504 500 tile+=40;
17505 500 break;
17506
17507 case left: //r
17508 315 flip=0;
17509 315 tile+=48;
17510 315 break;
17511
17512 case r_down: //ul
17513 196 flip=0;
17514 196 tile+=80;
17515 196 break;
17516
17517 case down: //ur
17518 215 flip=0;
17519 215 tile+=88;
17520 215 break;
17521
17522 case r_up: //dl
17523 164 flip=0;
17524 164 tile+=120;
17525 164 break;
17526
17527 case right: //dr
17528 288 flip=0;
17529 288 tile+=128;
17530 288 break;
17531 }
17532
17533 2518 tile+=(f2*2);
17534 2518 xofs-=8;
17535 2518 yofs-=8;
17536 2518 drawblock(dest,15);
17537 2518 xofs+=8;
17538 2518 yofs+=8;
17539 }
17540 21250 }
17541 else
17542 {
17543
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
17544 {
17545 8444 enemy::draw(dest);
17546 8444 }
17547 else
17548 {
17549 515 xofs-=8;
17550 515 yofs-=8;
17551 515 enemy::draw(dest);
17552 515 xofs+=16;
17553 515 enemy::draw(dest);
17554 515 yofs+=16;
17555 515 enemy::draw(dest);
17556 515 xofs-=16;
17557 515 enemy::draw(dest);
17558 515 xofs+=8;
17559 515 yofs-=8;
17560 }
17561 }
17562 30209 }
17563
17564 528 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
17565 528 {
17566 264 id=misc=clk;
17567 264 dir = clk & 3;
17568 264 clk=0;
17569 264 mainguy=count_enemy=false;
17570 264 dummy_bool[0]=false;
17571 264 item_set=0;
17572 264 bgsfx=-1;
17573 264 deadsfx = WAV_EDEAD;
17574 264 flags &= (~guy_neverret);
17575 264 isCore = false;
17576 //Probably will be buggy. -Z 12 AUG 2020
17577 264 SIZEflags = d->SIZEflags;
17578
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17579 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17580 // al_trace("Enemy txsz:%i\n", txsz);
17581
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17582
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17583
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17584
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17585
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17586
1/2
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17587 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17588
1/4
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17590 {
17591 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17592 }
17593
17594
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
264 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17595 264 }
17596
17597 95484 bool esManhandla::animate(int32_t index)
17598 {
17599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95484 times.
95484 if(switch_hooked) return enemy::animate(index);
17600
2/2
✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 91884 times.
95484 if(dying)
17601 3600 return Dead(index);
17602
17603
2/2
✓ Branch 0 taken 5865 times.
✓ Branch 1 taken 86019 times.
91884 if(clk==0)
17604 {
17605 5865 removearmos(x,y,ffcactivated);
17606 5865 }
17607
17608
2/2
✓ Branch 0 taken 78632 times.
✓ Branch 1 taken 13252 times.
91884 if(--clk2<=0)
17609 {
17610 13252 clk2=unsigned(zc_oldrand())%5+5;
17611 13252 clk3^=1;
17612 13252 }
17613
17614
2/2
✓ Branch 0 taken 725 times.
✓ Branch 1 taken 91159 times.
91884 if(!(zc_oldrand()&127))
17615 {
17616 725 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
17617 725 sfx(wpnsfx(wpn),pan(int32_t(x)));
17618 725 }
17619
17620 91884 return enemy::animate(index);
17621 95484 }
17622
17623 95476 void esManhandla::draw(BITMAP *dest)
17624 {
17625 95476 tile=o_tile;
17626 95476 int32_t fdiv = frate/4;
17627
1/2
✓ Branch 0 taken 95476 times.
✗ Branch 1 not taken.
95476 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17628
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 25181 times.
95476 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17629 95476 efrate:((clk>=(frate>>1))?1:0);
17630
17631
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 25181 times.
95476 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17632 {
17633
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16874 times.
✓ Branch 2 taken 18626 times.
✓ Branch 3 taken 17275 times.
✓ Branch 4 taken 17520 times.
70295 switch(misc&3)
17634 {
17635 case up:
17636 16874 break;
17637
17638 case down:
17639 18626 tile+=4;
17640 18626 break;
17641
17642 case left:
17643 17275 tile+=8;
17644 17275 break;
17645
17646 case right:
17647 17520 tile+=12;
17648 17520 break;
17649 }
17650
17651 70295 tile+=f2;
17652 70295 }
17653 else
17654 {
17655
4/5
✓ Branch 0 taken 6148 times.
✓ Branch 1 taken 6702 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6921 times.
✓ Branch 4 taken 5410 times.
25181 switch(misc&3)
17656 {
17657 case down:
17658 6148 flip=2;
17659
17660 [[fallthrough]];
17661 case up:
17662 13069 tile=(clk3)?188:189;
17663 13069 break;
17664
17665 case right:
17666 6702 flip=1;
17667 [[fallthrough]];
17668
17669 case left:
17670 12112 tile=(clk3)?186:187;
17671 12112 break;
17672 }
17673 }
17674
17675 95476 enemy::draw(dest);
17676 95476 }
17677
17678 176 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
17679 176 {
17680
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if ( !(editorflags & ENEMY_FLAG5) )
17681 {
17682
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 x = 120;
17683
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 y = 48;
17684 88 }
17685 else
17686 {
17687 if ( !(editorflags & ENEMY_FLAG6) )
17688 {
17689 x = X; y = Y;
17690 }
17691 else
17692 {
17693 x = X+8; y = Y;
17694 }
17695 }
17696 88 hzsz = 32; // can't be jumped.
17697 88 flameclk=0;
17698 88 misc=clk; // total head count
17699 88 clk3=clk; // live head count
17700 88 clk=0;
17701 88 clk2=60; // fire ball clock
17702 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
17703
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
17704 88 dir = down;
17705 88 hxofs=4;
17706 88 hxsz=8;
17707 // frate=17*4;
17708 88 fading=fade_blue_poof;
17709 //nets+5420;
17710
3/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 23 times.
88 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17711 {
17712 /*
17713 necktile=o_tile+8;
17714 if (dmisc3)
17715 {
17716 necktile+=8;
17717 }
17718 */
17719 65 necktile=o_tile+dmisc6;
17720 65 }
17721 else
17722 {
17723 23 necktile=s_tile;
17724 }
17725 88 }
17726
17727 67285 bool eGleeok::animate(int32_t index)
17728 {
17729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67285 times.
67285 if(switch_hooked) return enemy::animate(index);
17730
2/2
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 66079 times.
67285 if(dying)
17731 1206 return Dead(index);
17732
17733
2/2
✓ Branch 0 taken 65778 times.
✓ Branch 1 taken 301 times.
66079 if(clk==0)
17734 {
17735 301 removearmos(x,y,ffcactivated);
17736 301 }
17737
17738 // Check if a head was killed somehow...
17739
2/2
✓ Branch 0 taken 34806 times.
✓ Branch 1 taken 31273 times.
66079 if(index+1+clk3>=guys.Count())
17740 31273 clk3=guys.Count()-index-1;
17741
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 52275 times.
66079 if(index+1+misc>=guys.Count())
17742 52275 misc=guys.Count()-index-1;
17743
17744 //fix for the "kill all enemies" item
17745
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 6 times.
66079 if(hp==-1000)
17746 {
17747
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
17748 {
17749 // I haven't seen this fail, but it seems like it ought to be
17750 // possible, so I'm checking for it. - Saf
17751
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17752 break;
17753 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
17754 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
17755 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
17756 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
17757 12 }
17758
17759 6 clk3=0;
17760
17761
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
17762 {
17763
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17764 break;
17765 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17766 12 }
17767 6 }
17768
17769
2/2
✓ Branch 0 taken 152852 times.
✓ Branch 1 taken 66079 times.
218931 for(int32_t i=0; i<clk3; i++)
17770 {
17771 152852 enemy *head = ((enemy*)guys.spr(index+i+1));
17772 152852 head->dummy_int[1]=necktile;
17773 152852 head->parent_script_UID = this->script_UID;
17774
17775
2/2
✓ Branch 0 taken 98803 times.
✓ Branch 1 taken 54049 times.
152852 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17776 {
17777 98803 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
17778 98803 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
17779 98803 }
17780 else
17781 {
17782 54049 head->dummy_int[2]=necktile+1; //connected head tile
17783 54049 head->dummy_int[3]=necktile+2; //flying head tile
17784 }
17785
17786 152852 head->dmisc5=dmisc5; //neck segments
17787
17788 /*
17789 if (dmisc3)
17790 {
17791 head->dummy_bool[0]=true;
17792 }
17793 */
17794
2/2
✓ Branch 0 taken 150189 times.
✓ Branch 1 taken 2663 times.
152852 if(head->hclk)
17795 {
17796
2/2
✓ Branch 0 taken 2118 times.
✓ Branch 1 taken 545 times.
2663 if(hclk==0)
17797 {
17798 545 hp -= 1000 - head->hp;
17799 545 hclk = 33;
17800
17801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 545 times.
545 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
17802
17803 545 sfx(WAV_EHIT,pan(int32_t(head->x)));
17804 545 }
17805
17806 2663 head->hclk = 0;
17807 2663 }
17808
17809 // Must be set in case of naughty ZScripts
17810 152852 head->hp = 1000;
17811 152852 }
17812
17813
2/2
✓ Branch 0 taken 65893 times.
✓ Branch 1 taken 186 times.
66079 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
17814 {
17815 186 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
17816 186 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
17817 186 }
17818
17819
2/2
✓ Branch 0 taken 18578 times.
✓ Branch 1 taken 47501 times.
66079 if(!dmisc3)
17820 {
17821
4/4
✓ Branch 0 taken 2631 times.
✓ Branch 1 taken 44870 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 1990 times.
47501 if(++clk2>72 && !(zc_oldrand()&3))
17822 {
17823 641 int32_t i=zc_oldrand()%misc;
17824 641 enemy *head = ((enemy*)guys.spr(index+i+1));
17825 641 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
17826 641 sfx(wpnsfx(wpn),pan(int32_t(x)));
17827 641 clk2=0;
17828 641 }
17829 47501 }
17830 else
17831 {
17832
4/4
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 17799 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 181 times.
18578 if(++clk2>100 && !(zc_oldrand()&3))
17833 {
17834 181 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
17835 181 head->timer=zc_oldrand()%50+50;
17836 181 clk2=0;
17837 181 }
17838 }
17839
17840
3/4
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 66012 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 67 times.
66079 if((hp<=0 && !immortal))
17841 {
17842
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 67 times.
247 for(int32_t i=0; i<misc; i++)
17843 180 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17844
17845
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 64 times.
67 if(flags&guy_neverret) never_return(index);
17846 67 }
17847
17848 66079 return enemy::animate(index);
17849 67285 }
17850
17851 150 int32_t eGleeok::takehit(weapon*,weapon*)
17852 {
17853 150 return 0;
17854 }
17855
17856 67602 void eGleeok::draw(BITMAP *dest)
17857 {
17858 67602 tile=o_tile;
17859
17860
2/2
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 66396 times.
67602 if(dying)
17861 {
17862 1206 enemy::draw(dest);
17863 1206 return;
17864 }
17865
17866 66396 int32_t f=clk/17;
17867
17868
2/2
✓ Branch 0 taken 43721 times.
✓ Branch 1 taken 22675 times.
66396 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17869 {
17870 // body
17871 43721 xofs=-8;
17872 43721 yofs=32;
17873
17874
4/4
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 3364 times.
✓ Branch 3 taken 3289 times.
43721 switch(f)
17875
17876 {
17877 case 0:
17878 3611 tile+=0;
17879 3611 break;
17880
17881 case 1:
17882 3364 tile+=2;
17883 3364 break;
17884
17885 case 2:
17886 3289 tile+=4;
17887 3289 break;
17888
17889 default:
17890 33457 tile+=6;
17891 33457 break;
17892 }
17893 43721 }
17894 else
17895 {
17896 // body
17897 22675 xofs=-8;
17898 22675 yofs=32;
17899
17900
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
17901 {
17902 case 0:
17903 1645 tile+=0;
17904 1645 break;
17905
17906 case 2:
17907 1615 tile+=4;
17908 1615 break;
17909
17910 default:
17911 19415 tile+=2;
17912 19415 break;
17913 }
17914 }
17915
17916 66396 enemy::drawblock(dest,15);
17917 67602 }
17918
17919 67602 void eGleeok::draw2(BITMAP *dest)
17920 {
17921 // the neck stub
17922 67602 tile=necktile;
17923 67602 xofs=0;
17924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67602 times.
67602 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17925
17926
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 44531 times.
67602 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17927 {
17928 44531 tile+=((clk&24)>>3);
17929 44531 }
17930
17931
3/4
✓ Branch 0 taken 66396 times.
✓ Branch 1 taken 1206 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66396 times.
67602 if(hp > 0 && !dont_draw())
17932 {
17933
3/4
✓ Branch 0 taken 637 times.
✓ Branch 1 taken 65759 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 637 times.
66396 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
17934 sprite::drawcloaked(dest);
17935 else
17936 66396 sprite::draw(dest);
17937 66396 }
17938 67602 }
17939
17940
4/8
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 259 times.
✗ Branch 7 not taken.
777 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17941 518 {
17942
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 xoffset=0;
17943
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 yoffset=(zfix)((dmisc5*4+2));
17944 // dummy_bool[0]=false;
17945 259 timer=0;
17946 /* fixing */
17947 259 hp=1000;
17948
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 step=1;
17949 259 item_set=0;
17950 //x=120; y=70;
17951
4/8
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 259 times.
✗ Branch 7 not taken.
259 x = xoffset+parent->x;
17952
4/8
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 259 times.
✗ Branch 7 not taken.
259 y = yoffset+parent->y;
17953 259 hxofs=4;
17954 259 hxsz=8;
17955
3/6
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
259 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17956 259 clk2=clk; // how int32_t to wait before moving first time
17957 259 clk=0;
17958 259 mainguy=count_enemy=false;
17959
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 dir=zc_oldrand();
17960 259 clk3=((dir&2)>>1)+2; // left or right
17961 259 dir&=1; // up or down
17962
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 dmisc5=vbound(dmisc5,1,255);
17963 259 isCore = false;
17964
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 parentCore = parent->getUID();
17965
2/2
✓ Branch 0 taken 1036 times.
✓ Branch 1 taken 259 times.
1295 for(int32_t i=0; i<dmisc5; i++)
17966 {
17967 1036 nxoffset[i] = 0;
17968 1036 nyoffset[i] = 0;
17969
2/4
✓ Branch 0 taken 1036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1036 times.
✗ Branch 3 not taken.
1036 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
17970
2/4
✓ Branch 0 taken 1036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1036 times.
✗ Branch 3 not taken.
1036 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
17971 1036 }
17972
17973 259 necktile=0;
17974 //TODO compatibility? -DD
17975 /*
17976 for(int32_t i=0; i<4; i++)
17977 {
17978 nx[i]=124;
17979 ny[i]=i*6+48;
17980 }*/
17981 259 bgsfx=-1;
17982 //no need for deadsfx
17983 259 }
17984
17985 197318 bool esGleeok::animate(int32_t index)
17986 {
17987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 197318 times.
197318 if(switch_hooked) return enemy::animate(index);
17988 // don't call removearmos() - it's a segment.
17989
17990 197318 dmisc5=vbound(dmisc5,1,255);
17991
17992
2/2
✓ Branch 0 taken 44646 times.
✓ Branch 1 taken 152672 times.
197318 if(misc == 0)
17993 {
17994 152672 x = (xoffset+parent->x);
17995 152672 y = (yoffset+parent->y);
17996
17997
2/2
✓ Branch 0 taken 610688 times.
✓ Branch 1 taken 152672 times.
763360 for(int32_t i=0; i<dmisc5; i++)
17998 {
17999 610688 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
18000 610688 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
18001 610688 }
18002 152672 }
18003
18004 // set up the head tiles
18005 // headtile=nets+5588; //5580, actually. must adjust for direction later on
18006 /*
18007 if (dummy_bool[0]) //if this is a flame gleeok
18008 {
18009 headtile+=180;
18010 }
18011 */
18012 197318 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
18013 197318 flyingheadtile=dummy_int[3];
18014
18015 // set up the neck tiles
18016 197318 necktile=dummy_int[1];
18017
18018
2/2
✓ Branch 0 taken 122856 times.
✓ Branch 1 taken 74462 times.
197318 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18019 {
18020 122856 necktile+=((clk&24)>>3);
18021 122856 }
18022
18023 /*
18024 else
18025 {
18026 necktile=145;
18027 }
18028 */
18029 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
18030
18031
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152672 times.
✓ Branch 2 taken 44323 times.
✓ Branch 3 taken 131 times.
✓ Branch 4 taken 192 times.
197318 switch(misc)
18032 {
18033 case 0: // live head
18034 // set up the attached head tiles
18035 152672 tile=headtile;
18036
18037
2/2
✓ Branch 0 taken 98694 times.
✓ Branch 1 taken 53978 times.
152672 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18038 {
18039 98694 tile+=((clk&24)>>3);
18040 /*
18041 if (dummy_bool[0]) {
18042 tile+=1561;
18043 }
18044 */
18045 98694 }
18046
18047 /*
18048 else
18049 {
18050 tile=146;
18051 }
18052 */
18053
4/4
✓ Branch 0 taken 38924 times.
✓ Branch 1 taken 113748 times.
✓ Branch 2 taken 4336 times.
✓ Branch 3 taken 34588 times.
152672 if(++clk2>=0 && !(clk2&3))
18054 {
18055
2/2
✓ Branch 0 taken 33832 times.
✓ Branch 1 taken 756 times.
34588 if(y<= (int32_t)parent->y + 8) dir=down;
18056
18057
2/2
✓ Branch 0 taken 33871 times.
✓ Branch 1 taken 717 times.
34588 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
18058
18059
4/4
✓ Branch 0 taken 3607 times.
✓ Branch 1 taken 30981 times.
✓ Branch 2 taken 3510 times.
✓ Branch 3 taken 97 times.
34588 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
18060 {
18061 97 dir^=1;
18062 97 }
18063
18064 34588 zfix tempx = x;
18065 34588 zfix tempy = y;
18066
18067 34588 sprite::move(step);
18068 34588 xoffset += (x-tempx);
18069 34588 yoffset += (y-tempy);
18070
18071
2/2
✓ Branch 0 taken 1441 times.
✓ Branch 1 taken 33147 times.
34588 if(clk2>=4)
18072 {
18073 1441 clk3^=1;
18074 1441 clk2=-4;
18075 1441 }
18076 else
18077 {
18078
2/2
✓ Branch 0 taken 32808 times.
✓ Branch 1 taken 339 times.
33147 if(x <= (int32_t)parent->x-(dmisc5*6))
18079 {
18080 339 clk3=right;
18081 339 }
18082
18083
2/2
✓ Branch 0 taken 32776 times.
✓ Branch 1 taken 371 times.
33147 if(x >= (int32_t)parent->x+(dmisc5*6))
18084 {
18085 371 clk3=left;
18086 371 }
18087
18088
4/4
✓ Branch 0 taken 22330 times.
✓ Branch 1 taken 10817 times.
✓ Branch 2 taken 20970 times.
✓ Branch 3 taken 1360 times.
33147 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
18089 {
18090 1360 clk3^=1; // x jig
18091 1360 }
18092 else
18093 {
18094
4/4
✓ Branch 0 taken 10913 times.
✓ Branch 1 taken 20874 times.
✓ Branch 2 taken 10584 times.
✓ Branch 3 taken 329 times.
31787 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
18095 {
18096 329 clk3^=1; // x switch back
18097 329 }
18098
18099 31787 clk2=-4;
18100 }
18101 }
18102
18103 34588 zc_swap(dir,clk3);
18104 34588 tempx = x;
18105 34588 tempy = y;
18106 34588 sprite::move(step);
18107 34588 xoffset += (x-tempx);
18108 34588 yoffset += (y-tempy);
18109 34588 zc_swap(dir,clk3);
18110
18111
2/2
✓ Branch 0 taken 103764 times.
✓ Branch 1 taken 34588 times.
138352 for(int32_t i=1; i<dmisc5; i++)
18112 {
18113 103764 nxoffset[i] = (zc_oldrand()%3);
18114 103764 nyoffset[i] = (zc_oldrand()%3);
18115 103764 }
18116 34588 }
18117
18118 152672 break;
18119
18120 case 1: // flying head
18121
2/2
✓ Branch 0 taken 2737 times.
✓ Branch 1 taken 41586 times.
44323 if(clk>=0)
18122
18123 {
18124 41586 variable_walk_8(rate,homing,hrate,spw_floater);
18125 41586 }
18126
18127 44323 break;
18128
18129 // the following are messages sent from the main guy...
18130 case -1: // got chopped off
18131 {
18132 131 misc=1;
18133 131 superman=1;
18134 131 hxofs=xofs=0;
18135 131 hxsz=16;
18136 131 cs=8;
18137 131 clk=-24;
18138 131 clk2=40;
18139 131 dir=(zc_oldrand()&7)+8;
18140 131 step=8.0/9.0;
18141 }
18142 131 break;
18143
18144 case -2: // the big guy is dead
18145 192 return true;
18146 }
18147
18148
2/2
✓ Branch 0 taken 184800 times.
✓ Branch 1 taken 12326 times.
197126 if(timer)
18149 {
18150
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 1469 times.
12326 if(!(timer%8))
18151 {
18152 1469 FireBreath(true);
18153 1469 }
18154
18155 12326 --timer;
18156 12326 }
18157
18158 197126 return enemy::animate(index);
18159 197318 }
18160
18161 3299 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
18162 {
18163
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3299 if ((editorflags & ENEMY_FLAG7) && misc == 1)
18164 {
18165 int32_t wpnId = w->id;
18166
18167 if(dying)
18168 return 0;
18169
18170 switch(wpnId)
18171 {
18172 case wLitBomb:
18173 case wLitSBomb:
18174 case wBait:
18175 case wWhistle:
18176 case wFire:
18177 case wWind:
18178 case wSSparkle:
18179 case wFSparkle:
18180 case wPhantom:
18181 return 0;
18182
18183 case wHookshot:
18184 case wBrang:
18185 case wBeam:
18186 case wArrow:
18187 case wMagic:
18188 case wBomb:
18189 case wSBomb:
18190 sfx(WAV_CHINK,pan(int32_t(x)));
18191 break;
18192 default:
18193 break;
18194 }
18195
18196 return 1;
18197 }
18198 else
18199 {
18200 3299 int32_t ret = enemy::takehit(w,realweap);
18201
18202
2/2
✓ Branch 0 taken 636 times.
✓ Branch 1 taken 2663 times.
3299 if(ret==-1)
18203 2663 return 2; // force it to wait a frame before checking sword attacks again
18204
18205 636 return ret;
18206 }
18207 3299 }
18208
18209 198003 void esGleeok::draw(BITMAP *dest)
18210 {
18211 198003 dmisc5=vbound(dmisc5,1,255);
18212
18213
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 153561 times.
✓ Branch 2 taken 44442 times.
198003 switch(misc)
18214 {
18215 case 0: //neck
18216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153561 times.
153561 if(!dont_draw())
18217 {
18218
2/2
✓ Branch 0 taken 460683 times.
✓ Branch 1 taken 153561 times.
614244 for(int32_t i=1; i<dmisc5; i++) //draw the neck
18219 {
18220
2/2
✓ Branch 0 taken 298542 times.
✓ Branch 1 taken 162141 times.
460683 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18221 {
18222
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298542 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18223 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
18224 else
18225 298542 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
18226 298542 }
18227 else
18228 {
18229
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4278 times.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18230 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
18231 else
18232 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
18233 }
18234 460683 }
18235 153561 }
18236
18237 153561 break;
18238
18239 case 1: //flying head
18240 44442 tile=flyingheadtile;
18241
18242
2/2
✓ Branch 0 taken 20413 times.
✓ Branch 1 taken 24029 times.
44442 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18243 {
18244 24029 tile+=((clk&24)>>3);
18245 24029 break;
18246 }
18247
18248 /*
18249 else
18250 {
18251 tile=(clk&1)?147:148;
18252 break;
18253 }
18254 */
18255 20413 }
18256 198003 }
18257
18258 198003 void esGleeok::draw2(BITMAP *dest)
18259 {
18260 198003 enemy::draw(dest);
18261 198003 }
18262
18263 104 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
18264 104 {
18265
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if ( !(editorflags & ENEMY_FLAG5) )
18266 {
18267
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 x = 128;
18268
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 y = 48;
18269 52 }
18270 else { x = X; y = Y; }
18271 52 adjusted=false;
18272
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 dir=(zc_oldrand()&7)+8;
18273 //step=0.25;
18274 52 flycnt=dmisc1;
18275 52 flycnt2=dmisc2;
18276 52 loopcnt=0;
18277 52 clk4 = 0;
18278 52 clk5 = 0;
18279 52 clk6 = 0;
18280 52 clk7 = 0;
18281
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
18282 52 SIZEflags = d->SIZEflags;
18283
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
18284
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
18285 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
18286 // al_trace("Enemy txsz:%i\n", txsz);
18287
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
18288
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
18289
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
18290
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 else if (dmisc10 == 1) hxsz = 32;
18291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
18292
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
18293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
18294
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 else if (dmisc10 == 1) hxofs = -8;
18295
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
18296 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
18297
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
18298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 else if (dmisc10 == 1) xofs = -8;
18299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
18300 {
18301 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
18302 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
18303 }
18304
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
52 else if (dmisc10 == 1) yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
18305
1/2
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
52 if (editorflags & ENEMY_FLAG8) misc = 1;
18306
18307
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
18308
18309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (dmisc29 == 0)
18310 {
18311
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 33 times.
52 if(!dmisc4)
18312 {
18313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
18314 33 else dmisc29 = (84 / 3);
18315 33 }
18316 else
18317 {
18318
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc29 = (90 / 2);
18319 19 else dmisc29 = (84 / 2);
18320 }
18321 52 }
18322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (dmisc30 == 0)
18323 {
18324
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 33 times.
52 if(!dmisc4)
18325 {
18326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
18327 33 else dmisc30 = (84 / 3)*0.5;
18328 33 }
18329 else
18330 {
18331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc30 = (90 / 2)*0.5;
18332 19 else dmisc30 = (84 / 2)*0.5;
18333 }
18334 52 }
18335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (dmisc31 == 0)
18336 {
18337
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 33 times.
52 if(!dmisc4)
18338 {
18339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
18340 33 else dmisc31 = (84 / 3)*2;
18341 33 }
18342 else
18343 {
18344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc31 = (90 / 2)*0.5;
18345 19 else dmisc31 = (84 / 2)*0.5;
18346 }
18347 52 }
18348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if (dmisc32 == 0)
18349 {
18350
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 33 times.
52 if(!dmisc4)
18351 {
18352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
18353 33 else dmisc32 = (84 / 3);
18354 33 }
18355 else
18356 {
18357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if (dmisc10) dmisc32 = (90 / 2)*0.25;
18358 19 else dmisc32 = (84 / 2)*0.25;
18359 }
18360 52 }
18361 52 }
18362
18363 62324 bool ePatra::animate(int32_t index)
18364 {
18365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62324 times.
62324 if(switch_hooked) return enemy::animate(index);
18366
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 61532 times.
62324 if(dying)
18367 {
18368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
18369 {
18370 ((enemy*)guys.spr(i))->hp = -1000;
18371 }
18372
18373 792 return Dead(index);
18374 }
18375
18376 61532 double basesize = 84;
18377
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 if (dmisc10) basesize = 90;
18378 61532 double halfsize = basesize / 2;
18379 61532 double quartersize = halfsize / 2;
18380 61532 double twothirdsize = (basesize / 3)*2;
18381 61532 double onethirdsize = (basesize / 3);
18382
18383
18384
2/2
✓ Branch 0 taken 13665 times.
✓ Branch 1 taken 47867 times.
61532 if(clk==0)
18385 {
18386 13665 removearmos(x,y,ffcactivated);
18387 13665 }
18388
18389
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61532 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61532 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61532 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
18390 {
18391
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61532 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
18392
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 if (loopcnt < 0) ++clk2;
18393
2/2
✓ Branch 0 taken 60837 times.
✓ Branch 1 taken 695 times.
61532 if(++clk2>basesize)
18394 {
18395 695 clk2=0;
18396
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
18397 {
18398
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
18399 361 --loopcnt;
18400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
18401 {
18402
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
18403 {
18404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
18405 128 else loopcnt=dmisc7;
18406 128 }
18407 334 }
18408 else if (loopcnt == -1) loopcnt=dmisc7;
18409 else ++loopcnt;
18410
18411
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
18412 695 }
18413 else
18414 {
18415 loopcnt = 0;
18416 misc = 1;
18417 }
18418 695 }
18419 61532 }
18420
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 if (clk4 > 0) --clk4;
18421
18422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61532 times.
61532 if (clk6 < 0)
18423 {
18424 if (dmisc5 == 1 || dmisc5 == 3)
18425 {
18426 if (get_bit(quest_rules,qr_NEWENEMYTILES))
18427 {
18428 if (clk7 <= 0 || clk6 != -16) ++clk6;
18429 if (clk6 == 0) o_tile=d->e_tile;
18430 else
18431 {
18432 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
18433 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
18434 }
18435 }
18436 else clk6 = 0;
18437 }
18438 }
18439
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 else if (dmisc19) ++clk6;
18440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61532 times.
61532 if (clk5 < 0) ++clk5;
18441
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 else if (dmisc19) ++clk5;
18442
18443
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61532 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61532 if (clk7 > 0 && clk6 >= -16) --clk7;
18444
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 if (clk6 > 0) clk7 = 0;
18445
18446
2/2
✓ Branch 0 taken 243988 times.
✓ Branch 1 taken 61532 times.
305520 for(int32_t i=index+1; i<index+flycnt+1; i++)
18447 {
18448 //outside ring
18449
2/2
✓ Branch 0 taken 243572 times.
✓ Branch 1 taken 416 times.
243988 if(!adjusted)
18450 {
18451
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 144 times.
416 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18452 {
18453 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
18454 272 enemy *s = ((enemy*)guys.spr(i));
18455 272 s->parent_script_UID = this->script_UID;
18456 272 }
18457 else
18458 {
18459 144 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18460 144 enemy *s = ((enemy*)guys.spr(i));
18461 144 s->parent_script_UID = this->script_UID;
18462 }
18463
18464 416 ((enemy*)guys.spr(i))->cs=dmisc9;
18465 416 ((enemy*)guys.spr(i))->hp=dmisc3;
18466 416 }
18467
18468
2/2
✓ Branch 0 taken 357 times.
✓ Branch 1 taken 243631 times.
243988 if(((enemy*)guys.spr(i))->hp <= 0)
18469 {
18470
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 357 times.
1635 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18471 {
18472 1278 guys.swap(j,j+1);
18473 1278 }
18474
18475
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
357 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
18476 357 }
18477 else
18478 {
18479 243631 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18480
1/2
✓ Branch 0 taken 243631 times.
✗ Branch 1 not taken.
243631 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
18481
18482
2/2
✓ Branch 0 taken 86815 times.
✓ Branch 1 taken 156816 times.
243631 if(!dmisc4) //Big Ring
18483 {
18484 //maybe playing_field_offset here?
18485
2/2
✓ Branch 0 taken 71944 times.
✓ Branch 1 taken 84872 times.
156816 if(loopcnt>0)
18486 {
18487
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18488
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18489 84872 }
18490 else
18491 {
18492 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18493 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18494 }
18495
18496 156816 temp_x=guys.spr(i)->x;
18497 156816 temp_y=guys.spr(i)->y;
18498 156816 }
18499 else //Oval
18500 {
18501 86815 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18502 86815 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18503
18504
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36673 times.
86815 if(loopcnt>0)
18505 {
18506 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50142 times.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
18508 50142 }
18509 else
18510 {
18511 36673 guys.spr(i)->x = circle_x;
18512 36673 guys.spr(i)->y = circle_y;
18513 }
18514
18515 86815 temp_x=circle_x;
18516 86815 temp_y=circle_y;
18517 }
18518
18519 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18520 243631 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18521
18522
4/4
✓ Branch 0 taken 46188 times.
✓ Branch 1 taken 197443 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30920 times.
243631 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18523 {
18524 30920 guys.spr(i)->dir=l_down;
18525 30920 }
18526
4/4
✓ Branch 0 taken 46236 times.
✓ Branch 1 taken 166475 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30968 times.
212711 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18527 {
18528 30968 guys.spr(i)->dir=left;
18529 30968 }
18530
4/4
✓ Branch 0 taken 45970 times.
✓ Branch 1 taken 135773 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30702 times.
181743 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18531 {
18532 30702 guys.spr(i)->dir=l_up;
18533 30702 }
18534
4/4
✓ Branch 0 taken 45616 times.
✓ Branch 1 taken 105425 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30348 times.
151041 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18535 {
18536 30348 guys.spr(i)->dir=up;
18537 30348 }
18538
4/4
✓ Branch 0 taken 45391 times.
✓ Branch 1 taken 75302 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30123 times.
120693 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18539 {
18540 30123 guys.spr(i)->dir=r_up;
18541 30123 }
18542
4/4
✓ Branch 0 taken 45243 times.
✓ Branch 1 taken 45327 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 29975 times.
90570 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18543 {
18544 29975 guys.spr(i)->dir=right;
18545 29975 }
18546
4/4
✓ Branch 0 taken 45326 times.
✓ Branch 1 taken 15269 times.
✓ Branch 2 taken 15268 times.
✓ Branch 3 taken 30058 times.
60595 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18547 {
18548 30058 guys.spr(i)->dir=r_down;
18549 30058 }
18550 else
18551 {
18552 30537 guys.spr(i)->dir=down;
18553 }
18554
18555 243631 guys.spr(i)->x += x;
18556 243631 guys.spr(i)->y += y;
18557 }
18558 243988 }
18559
18560
7/22
✓ Branch 0 taken 39916 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39916 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61532 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
18561 {
18562 15803 int timeneeded = 48;
18563 15803 int patbreath = (zc_oldrand()%50+50);
18564
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
18565
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
18566 {
18567 timeneeded = 48 + patbreath;
18568 }
18569
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
18570 {
18571 timeneeded = 48 + 96;
18572 }
18573
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
18574
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
18575
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18576 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)))))
18577 133 && (clk6 >= 0) //if not in the middle of firing...
18578 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
18579
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
18580 {
18581
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
18582 {
18583 case patratSTREAM:
18584 {
18585 clk7 = 97;
18586 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18587 else clk6 = 0;
18588 break;
18589 }
18590 case patratBREATH:
18591 {
18592 clk7 = patbreath;
18593 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18594 else clk6 = 0;
18595 break;
18596 }
18597 default:
18598 {
18599
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18600 {
18601 clk6 = -48;
18602 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18603 }
18604 else
18605 {
18606 133 clk6 = 0;
18607
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18608 133 FirePatraWeapon();
18609 }
18610 133 break;
18611 }
18612 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18613 133 }
18614
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
18615 {
18616 switch(dmisc28)
18617 {
18618 case patratSTREAM:
18619 {
18620 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
18621 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18622 break;
18623 }
18624 case patratBREATH:
18625 {
18626 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
18627 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18628 break;
18629 }
18630 default:
18631 {
18632 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && clk6 == -16)
18633 {
18634 FirePatraWeapon();
18635 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18636 }
18637 break;
18638 }
18639 }
18640 }
18641 15803 }
18642
18643 61532 int randattempts = 0;
18644 61532 int randeye = 0;
18645
2/2
✓ Branch 0 taken 44930 times.
✓ Branch 1 taken 16602 times.
61532 if (flycnt2 > 0)
18646 {
18647 16602 do
18648 {
18649
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
18650 16602 randeye += (index + flycnt + 1);
18651 16602 ++randattempts;
18652
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
18653 16602 }
18654 61532 bool dofire = false;
18655
1/2
✓ Branch 0 taken 61532 times.
✗ Branch 1 not taken.
61532 if (dmisc20)
18656 {
18657 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18658 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
18659 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
18660 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) || dmisc20 == 2))
18661 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
18662 {
18663 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18664 {
18665 if (clk5 >= dmisc19)
18666 {
18667 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18668 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
18669 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
18670 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
18671 || dmisc18 == -1)
18672 dofire = true;
18673 }
18674 }
18675 }
18676 }
18677
2/2
✓ Branch 0 taken 44930 times.
✓ Branch 1 taken 16602 times.
61532 if(flycnt2)
18678 {
18679
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
18680 {
18681
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
18682 {
18683 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
18684
18685
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18686 {
18687
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18688 {
18689
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
18690 {
18691 // Center eye shoots projectiles; make room for its firing tiles
18692 case 1:
18693 case 3:
18694 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
18695 48 break;
18696
18697 // Center eyes does not shoot; use tiles two rows below for inner eyes.
18698 default:
18699 case 2:
18700 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
18701 40 break;
18702 }
18703 88 }
18704 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
18705 88 }
18706 else
18707 {
18708 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18709 }
18710
18711 88 ((enemy*)guys.spr(i))->cs=dmisc9;
18712
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
18713 88 }
18714
18715
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
18716 {
18717 94136 ((enemy*)guys.spr(i))->superman=true;
18718 94136 }
18719 else
18720 {
18721 25839 ((enemy*)guys.spr(i))->superman=false;
18722 }
18723
18724
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
18725 {
18726
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18727 {
18728 144 guys.swap(j,j+1);
18729 144 }
18730
18731
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
18732 72 }
18733 else
18734 {
18735 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18736
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
18737
18738
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
18739 {
18740
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
18741 {
18742
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18743
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18744 58268 }
18745 else
18746 {
18747 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18748 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18749 }
18750
18751 112644 temp_x=guys.spr(i)->x;
18752 112644 temp_y=guys.spr(i)->y;
18753 112644 }
18754 else
18755 {
18756 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18757 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18758
18759
2/2
✓ Branch 0 taken 3294 times.
✓ Branch 1 taken 3965 times.
7259 if(loopcnt>0)
18760 {
18761 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18762
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
18763 3965 }
18764 else
18765 {
18766 3294 guys.spr(i)->x = circle_x;
18767 3294 guys.spr(i)->y = circle_y;
18768 }
18769
18770 7259 temp_x=circle_x;
18771 7259 temp_y=circle_y;
18772 }
18773
18774 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18775 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18776
18777
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18778 {
18779 14941 guys.spr(i)->dir=l_down;
18780 14941 }
18781
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18782 {
18783 14928 guys.spr(i)->dir=left;
18784 14928 }
18785
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18786 {
18787 14937 guys.spr(i)->dir=l_up;
18788 14937 }
18789
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18790 {
18791 14996 guys.spr(i)->dir=up;
18792 14996 }
18793
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18794 {
18795 15041 guys.spr(i)->dir=r_up;
18796 15041 }
18797
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18798 {
18799 15035 guys.spr(i)->dir=right;
18800 15035 }
18801
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18802 {
18803 15035 guys.spr(i)->dir=r_down;
18804 15035 }
18805 else
18806 {
18807 14990 guys.spr(i)->dir=down;
18808 }
18809
18810 119903 guys.spr(i)->x += x;
18811 119903 guys.spr(i)->y = y-guys.spr(i)->y;
18812
18813
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
18814 {
18815 /*
18816 if(!(zc_oldrand()&127))
18817 {
18818 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
18819 sfx(wpnsfx(wpn),pan(int32_t(x)));
18820 }
18821 */
18822
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
18823 {
18824 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
18825 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18826 {
18827 if (dmisc5 == 3)
18828 {
18829 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18830 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
18831 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
18832 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18833 }
18834 else
18835 {
18836 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18837 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18838 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
18839 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18840 }
18841 }
18842 else
18843 {
18844 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18845 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
18846 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
18847 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18848 }
18849 }
18850
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
18851
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
18852
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
18853 {
18854
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
18855 {
18856 case 4: //Single one rapidfires
18857 {
18858 if (dofire && i == randeye)
18859 {
18860 ((esPatra*)guys.spr(i))->clk5 = -16;
18861 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
18862 ((esPatra*)guys.spr(i))->clk4 = 96;
18863 clk5 = -3;
18864 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18865 }
18866 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
18867 {
18868 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18869 sfx(wpnsfx(wpn),pan(int32_t(x)));
18870 }
18871 break;
18872 }
18873 case 3: //Ring
18874 {
18875 if (dofire)
18876 {
18877 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18878 {
18879 ((esPatra*)guys.spr(i))->clk5 = -48;
18880 clk5 = -48;
18881 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18882 }
18883 else
18884 {
18885 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18886 sfx(wpnsfx(wpn),pan(int32_t(x)));
18887 int32_t m=Ewpns.Count()-1;
18888 weapon *ew = (weapon*)(Ewpns.spr(m));
18889
18890 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18891 ((esPatra*)guys.spr(i))->clk5 = 0;
18892 clk5 = 0;
18893 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18894 }
18895 }
18896 if (((esPatra*)guys.spr(i))->clk5 == -16)
18897 {
18898 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18899 sfx(wpnsfx(wpn),pan(int32_t(x)));
18900 int32_t m=Ewpns.Count()-1;
18901 weapon *ew = (weapon*)(Ewpns.spr(m));
18902
18903 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18904 }
18905 break;
18906 }
18907 case 2: //one after another
18908 {
18909 if (dofire)
18910 {
18911 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
18912 clk5 = -48 - (12*flycnt2);
18913 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18914 }
18915 if (((esPatra*)guys.spr(i))->clk5 == -16)
18916 {
18917 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18918 sfx(wpnsfx(wpn),pan(int32_t(x)));
18919 }
18920 break;
18921 }
18922 case 1: //random one eye
18923 {
18924 if (dofire && i == randeye)
18925 {
18926 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18927 {
18928 ((esPatra*)guys.spr(i))->clk5 = -48;
18929 clk5 = -48;
18930 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18931 }
18932 else
18933 {
18934 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18935 sfx(wpnsfx(wpn),pan(int32_t(x)));
18936 ((esPatra*)guys.spr(i))->clk5 = 0;
18937 clk5 = 0;
18938 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18939 }
18940 }
18941 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18942 {
18943 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18944 sfx(wpnsfx(wpn),pan(int32_t(x)));
18945 }
18946 break;
18947 }
18948 default: //old behavior, all eyes can fire any time
18949 {
18950
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18951
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18952
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18953 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
18954 {
18955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18956 {
18957 ((esPatra*)guys.spr(i))->clk5 = -48;
18958 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18959 }
18960 else
18961 {
18962 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18963 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
18964 292 ((esPatra*)guys.spr(i))->clk5 = 0;
18965
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18966 }
18967 292 }
18968
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18969 {
18970 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18971 sfx(wpnsfx(wpn),pan(int32_t(x)));
18972 }
18973 38077 break;
18974 }
18975 }
18976 38077 }
18977 38077 }
18978
18979 }
18980 119975 }
18981 16602 }
18982
18983 61532 adjusted=true;
18984 61532 return enemy::animate(index);
18985 62324 }
18986
18987 133 void ePatra::FirePatraWeapon()
18988 { //.707
18989 133 int32_t xoff = 0;
18990 133 int32_t yoff = 0;
18991
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
18992 {
18993 xoff += (hxsz/2)-8;
18994 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
18995 }
18996
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
18997 {
18998 yoff += (hysz/2)-8;
18999 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
19000 }
19001 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
19002
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
19003 {
19004 case patrat8SHOT: //Fire Wizzrobe
19005 case patrat4SHOTDIAG:
19006 case patrat4SHOTRAND:
19007 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
19008 {
19009 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
19010 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19011 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19012 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19013
19014 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
19015 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19016 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19017 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19018
19019 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
19020 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19021 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19022 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19023
19024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
19025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19027 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
19028
19029 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
19030 }
19031
19032 [[fallthrough]];
19033 case patrat4SHOTCARD: //Stalfos 3
19034 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
19035 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19036 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19037 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
19038 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19039 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19040 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
19041 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19042 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19043 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
19044 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19045 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
19046 break;
19047
19048 default:
19049 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19050
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
19051 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
19052
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19053
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19054 {
19055 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19056 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
19057 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19058 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19059 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19060 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
19061 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19062 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19063 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19064 {
19065 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19066 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
19067 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19068 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19069 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19070 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
19071 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19072 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19073 }
19074 }
19075 133 break;
19076
19077 }
19078 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
19079 //+0.46364761
19080 //11.80
19081 133 }
19082
19083 124842 void ePatra::draw(BITMAP *dest)
19084 {
19085 124842 tile=o_tile;
19086 124842 update_enemy_frame();
19087 124842 enemy::draw(dest);
19088 124842 }
19089
19090 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
19091 {
19092 int32_t ret = enemy::defend(wpnId, power, edef);
19093
19094 if(ret < 0 && (flycnt||flycnt2))
19095 return 0;
19096
19097 return ret;
19098 }
19099
19100 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19101 {
19102 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19103
19104
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
19105 660 return 0;
19106
19107 248 return ret;
19108 908 }
19109
19110 1512 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19111 1008 {
19112 //cs=8;
19113 504 item_set=0;
19114 504 misc=clk;
19115 504 clk4 = 0;
19116 504 clk5 = 0;
19117 504 clk = -((misc*21)>>1)-1;
19118
3/6
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 504 times.
✗ Branch 5 not taken.
504 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19119 504 hxsz=12;
19120 504 hysz=12;
19121 504 hxofs=2;
19122 504 hyofs=2;
19123 504 extend = 0;
19124 504 txsz = 1;
19125 504 tysz = 1;
19126 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
19127 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19128 int32_t prntSIZEflags = prntenemy->SIZEflags;
19129 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19130 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19131 // al_trace("Enemy txsz:%i\n", txsz);
19132 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19133 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19134 else
19135 hxsz=12;
19136 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19137 else
19138 hysz=12;
19139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19141 else
19142 hxofs=2;
19143 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19144 else hyofs=2;
19145 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19146 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19148 {
19149 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19150 }
19151
19152 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
19153 */
19154 504 mainguy=count_enemy=false;
19155 504 bgsfx=-1;
19156 //o_tile=0;
19157 504 flags &= (~guy_neverret);
19158 504 deadsfx = WAV_EDEAD;
19159 504 hitsfx = WAV_EHIT;
19160 504 isCore = false;
19161 504 }
19162
19163 371975 bool esPatra::animate(int32_t index)
19164 {
19165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 371975 times.
371975 if(switch_hooked) return enemy::animate(index);
19166
2/2
✓ Branch 0 taken 7722 times.
✓ Branch 1 taken 364253 times.
371975 if(dying)
19167 7722 return Dead(index);
19168
19169 364253 return enemy::animate(index);
19170 371975 }
19171
19172 746702 void esPatra::draw(BITMAP *dest)
19173 {
19174
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 201982 times.
746702 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19175 {
19176 544720 tile = o_tile+(clk&3);
19177
19178
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
19179 {
19180 case up: //u
19181 67770 flip=0;
19182 67770 break;
19183
19184 case down: //d
19185 69066 flip=0;
19186 69066 tile+=4;
19187 69066 break;
19188
19189 case left: //l
19190 67800 flip=0;
19191 67800 tile+=8;
19192 67800 break;
19193
19194 case right: //r
19195 67996 flip=0;
19196 67996 tile+=12;
19197 67996 break;
19198
19199 case l_up: //ul
19200 67484 flip=0;
19201 67484 tile+=20;
19202 67484 break;
19203
19204 case r_up: //ur
19205 68044 flip=0;
19206 68044 tile+=24;
19207 68044 break;
19208
19209 case l_down: //dl
19210 68474 flip=0;
19211 68474 tile+=28;
19212 68474 break;
19213
19214 case r_down: //dr
19215 68086 flip=0;
19216 68086 tile+=32;
19217 68086 break;
19218 }
19219 544720 }
19220 else
19221 {
19222 201982 tile = o_tile+((clk&2)>>1);
19223 }
19224
19225
2/2
✓ Branch 0 taken 37768 times.
✓ Branch 1 taken 708934 times.
746702 if(clk>=0)
19226 708934 enemy::draw(dest);
19227 746702 }
19228
19229
19230 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
19231 6 {
19232 3 adjusted=false;
19233
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
19234
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
19235 3 clk4 = 0;
19236 3 clk5 = 0;
19237 //flycnt=6; flycnt2=0;
19238 3 flycnt=dmisc1;
19239 3 flycnt2=0; // PatraBS doesn't have inner rings!
19240 3 loopcnt=0;
19241
19242 3 SIZEflags = d->SIZEflags;
19243
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19244 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19245 // al_trace("Enemy txsz:%i\n", txsz);
19246
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
19247
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
19248 3 else hxsz = 32;
19249
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
19250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
19251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
19252 3 else hxofs=-8;
19253
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
19254 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19255
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
19256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19257 {
19258 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19259 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
19260 }
19261
19262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
19263
19264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
19265
19266 //nets+4480;
19267 3 }
19268
19269 1862 bool ePatraBS::animate(int32_t index)
19270 {
19271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
19272
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
19273 54 return Dead(index);
19274
19275
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
19276 {
19277 442 removearmos(x,y,ffcactivated);
19278 442 }
19279
19280 1808 variable_walk_8(rate,homing,hrate,spw_floater);
19281
19282
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
19283 {
19284 19 clk2=0;
19285
19286
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
19287 12 --loopcnt;
19288 else
19289 {
19290
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
19291 4 loopcnt=dmisc7;
19292 }
19293
19294 19 ++misc;
19295 19 }
19296
19297 // double size=1;;
19298
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
19299 {
19300
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
19301 {
19302 18 ((enemy*)guys.spr(i))->hp=dmisc3;
19303
19304
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19305 {
19306 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
19307 18 }
19308 else
19309 {
19310 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
19311 }
19312
19313 18 ((enemy*)guys.spr(i))->cs = dmisc9;
19314 18 }
19315
19316
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
19317 {
19318
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
19319 {
19320 26 guys.swap(j,j+1);
19321 26 }
19322
19323 18 --flycnt;
19324 18 }
19325 else
19326 {
19327 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
19328
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
19329 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
19330 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
19331
19332
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
19333 {
19334 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
19335
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
19336 2305 }
19337 else
19338 {
19339 2132 guys.spr(i)->x = temp_x;
19340 2132 guys.spr(i)->y = temp_y;
19341 }
19342
19343 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19344 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
19345
19346
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19347 {
19348 551 guys.spr(i)->dir=l_down;
19349 551 }
19350
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19351 {
19352 534 guys.spr(i)->dir=left;
19353 534 }
19354
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19355 {
19356 522 guys.spr(i)->dir=l_up;
19357 522 }
19358
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19359 {
19360 564 guys.spr(i)->dir=up;
19361 564 }
19362
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19363 {
19364 545 guys.spr(i)->dir=r_up;
19365 545 }
19366
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19367 {
19368 562 guys.spr(i)->dir=right;
19369 562 }
19370
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19371 {
19372 554 guys.spr(i)->dir=r_down;
19373 554 }
19374 else
19375 {
19376 605 guys.spr(i)->dir=down;
19377 }
19378
19379 4437 guys.spr(i)->x += x;
19380 4437 guys.spr(i)->y += y;
19381 }
19382 4455 }
19383
19384 1808 adjusted=true;
19385 1808 return enemy::animate(index);
19386 1862 }
19387
19388 3724 void ePatraBS::draw(BITMAP *dest)
19389 {
19390 3724 tile=o_tile;
19391
19392
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19393 {
19394 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19395 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
19396
19397
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19398 {
19399 102 lookat=l_down;
19400 102 }
19401
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19402 {
19403 310 lookat=down;
19404 310 }
19405
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19406 {
19407 952 lookat=r_down;
19408 952 }
19409
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19410 {
19411 1686 lookat=right;
19412 1686 }
19413
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19414 {
19415 180 lookat=r_up;
19416 180 }
19417
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19418 {
19419 lookat=up;
19420 }
19421
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19422 {
19423 lookat=l_up;
19424 }
19425 else
19426 {
19427 494 lookat=left;
19428 }
19429
19430
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
19431 {
19432 case up: //u
19433 flip=0;
19434 break;
19435
19436 case down: //d
19437 310 flip=0;
19438 310 tile+=8;
19439 310 break;
19440
19441 case left: //l
19442 494 flip=0;
19443 494 tile+=40;
19444 494 break;
19445
19446 case right: //r
19447 1686 flip=0;
19448 1686 tile+=48;
19449 1686 break;
19450
19451 case l_up: //ul
19452 flip=0;
19453 tile+=80;
19454 break;
19455
19456 case r_up: //ur
19457 180 flip=0;
19458 180 tile+=88;
19459 180 break;
19460
19461 case l_down: //dl
19462 102 flip=0;
19463 102 tile+=120;
19464 102 break;
19465
19466 case r_down: //dr
19467 952 flip=0;
19468 952 tile+=128;
19469 952 break;
19470 }
19471
19472 3724 tile+=(2*(clk&3));
19473 3724 xofs-=8;
19474 3724 yofs-=8;
19475 3724 drawblock(dest,15);
19476 3724 xofs+=8;
19477 3724 yofs+=8;
19478 3724 }
19479 else
19480 {
19481 flip=(clk&1);
19482 xofs-=8;
19483 yofs-=8;
19484 enemy::draw(dest);
19485 xofs+=16;
19486 enemy::draw(dest);
19487 yofs+=16;
19488 enemy::draw(dest);
19489 xofs-=16;
19490 enemy::draw(dest);
19491 xofs+=8;
19492 yofs-=8;
19493 }
19494 3724 }
19495
19496 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
19497 {
19498 int32_t ret = enemy::defend(wpnId, power, edef);
19499
19500 if(ret < 0 && (flycnt||flycnt2))
19501 return 0;
19502
19503 return ret;
19504 }
19505
19506 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19507 {
19508 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19509
19510
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
19511 19 return 0;
19512
19513 6 return ret;
19514 25 }
19515
19516 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19517 36 {
19518 //cs=csBOSS;
19519 18 item_set=0;
19520 18 misc=clk;
19521 18 clk = -((misc*21)>>1)-1;
19522 18 clk4 = 0;
19523 18 clk5 = 0;
19524
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19525 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
19526
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19527 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19528 // al_trace("Enemy txsz:%i\n", txsz);
19529
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19531 18 else hxsz=16;
19532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19533 18 else hysz=16;
19534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19535
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19537 18 else hyofs=2;
19538 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19539
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19541 {
19542 yofs = (int32_t)prntenemy->yofs;
19543 }
19544
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19545
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
19546
19547 18 bgsfx=-1;
19548 18 mainguy=count_enemy=false;
19549 18 deadsfx = WAV_EDEAD;
19550 18 hitsfx = WAV_EHIT;
19551 18 flags &= ~guy_neverret;
19552 18 isCore = false;
19553 18 }
19554
19555 4790 bool esPatraBS::animate(int32_t index)
19556 {
19557
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
19558
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
19559 324 return Dead(index);
19560
19561 4466 return enemy::animate(index);
19562 4790 }
19563
19564 9580 void esPatraBS::draw(BITMAP *dest)
19565 {
19566 9580 tile=o_tile;
19567
19568
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19569 {
19570
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
19571 {
19572 case up: //u
19573 1280 flip=0;
19574 1280 break;
19575
19576 case down: //d
19577 1326 flip=0;
19578 1326 tile+=4;
19579 1326 break;
19580
19581 case left: //l
19582 1076 flip=0;
19583 1076 tile+=8;
19584 1076 break;
19585
19586 case right: //r
19587 1254 flip=0;
19588 1254 tile+=12;
19589 1254 break;
19590
19591 case l_up: //ul
19592 1080 flip=0;
19593 1080 tile+=20;
19594 1080 break;
19595
19596 case r_up: //ur
19597 1238 flip=0;
19598 1238 tile+=24;
19599 1238 break;
19600
19601 case l_down: //dl
19602 1146 flip=0;
19603 1146 tile+=28;
19604 1146 break;
19605
19606 case r_down: //dr
19607 1180 flip=0;
19608 1180 tile+=32;
19609 1180 break;
19610 }
19611
19612 9580 tile += ((clk&6)>>1);
19613 9580 }
19614 else
19615 {
19616 tile += (clk&4)?1:0;
19617 }
19618
19619
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
19620 8608 enemy::draw(dest);
19621 9580 }
19622
19623
19624 /**********************************/
19625 /********** Misc Code ***********/
19626 /**********************************/
19627
19628 151034 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
19629 {
19630
4/6
✓ Branch 0 taken 116952 times.
✓ Branch 1 taken 34082 times.
✓ Branch 2 taken 116952 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116952 times.
✗ Branch 5 not taken.
151034 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
19631
4/8
✓ Branch 0 taken 151034 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151034 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 151034 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 151034 times.
✗ Branch 7 not taken.
151034 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
19632
1/2
✓ Branch 0 taken 151034 times.
✗ Branch 1 not taken.
151034 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19633 151034 }
19634
19635 34367 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
19636 {
19637 // Kludge
19638
4/8
✓ Branch 0 taken 34367 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34367 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34367 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34367 times.
✗ Branch 7 not taken.
34367 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
19639 34367 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
19640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34367 times.
34367 delete w;
19641 34367 return ret;
19642 }
19643
19644 3789 void enemy_scored(int32_t index)
19645 {
19646 3789 ((enemy*)guys.spr(index))->scored=true;
19647 3789 }
19648
19649 1291 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy)
19650 {
19651
7/12
✓ Branch 0 taken 1291 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1291 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1291 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1291 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 1176 times.
✓ Branch 10 taken 1291 times.
✗ Branch 11 not taken.
1291 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_bit(quest_rules,qr_NOGUYPOOF)?0:clk,mainguy);
19652 1291 guys.add(g);
19653 1291 }
19654
19655 21943 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19656 {
19657
5/10
✓ Branch 0 taken 21943 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21943 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21943 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21943 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21943 times.
✗ Branch 9 not taken.
21943 item *i = new item(zfix(x), zfix(y - get_bit(quest_rules, qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
19658 21943 items.add(i);
19659 21943 }
19660
19661 70 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
19662 {
19663
6/12
✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 70 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 70 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 70 times.
✗ Branch 11 not taken.
70 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
19664 70 items.add(i);
19665 70 }
19666
19667 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19668 {
19669 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
19670 items.add(i);
19671 }
19672
19673 58 void kill_em_all()
19674 {
19675
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 58 times.
312 for(int32_t i=0; i<guys.Count(); i++)
19676 {
19677 254 enemy *e = ((enemy*)guys.spr(i));
19678
19679
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
254 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19680
19681 229 e->kickbucket();
19682 229 }
19683 58 }
19684
19685 bool can_kill_em_all()
19686 {
19687 for(int32_t i=0; i<guys.Count(); i++)
19688 {
19689 enemy *e = ((enemy*)guys.spr(i));
19690
19691 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19692 if(e->superman) continue;
19693 return true;
19694 }
19695 return false;
19696 }
19697
19698 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
19699 // For Hero's hit detection. Don't count them if they are stunned or are guys.
19700 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19701 {
19702 for(int32_t i=0; i<guys.Count(); i++)
19703 {
19704 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19705 {
19706 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
19707 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
19708 {
19709 return i;
19710 }
19711 }
19712 }
19713
19714 return -1;
19715 }
19716
19717 5922199 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19718 {
19719
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5922199 times.
✓ Branch 2 taken 17446892 times.
✓ Branch 3 taken 5908417 times.
23355309 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
19720 {
19721
2/2
✓ Branch 0 taken 13782 times.
✓ Branch 1 taken 17433110 times.
17446892 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19722 {
19723 13782 return i;
19724 }
19725 17433110 }
19726
19727 5908417 return -1;
19728 5922199 }
19729
19730 // For Hero's hit detection. Count them if they are dying.
19731 25716 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19732 {
19733 25716 enemy *e = (enemy*)guys.spr(index);
19734
3/4
✓ Branch 0 taken 25716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14117 times.
✓ Branch 3 taken 11599 times.
25716 if(!e || e->hp > 0)
19735 14117 return -1;
19736
19737 11599 bool d = e->dying;
19738 11599 int32_t hc = e->hclk;
19739 11599 e->dying = false;
19740 11599 e->hclk = 0;
19741 11599 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
19742 11599 e->dying = d;
19743 11599 e->hclk = hc;
19744
19745
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 11518 times.
11599 return hit ? index : -1;
19746 25716 }
19747
19748 6441907 bool hasMainGuy()
19749 {
19750
2/2
✓ Branch 0 taken 7998935 times.
✓ Branch 1 taken 2319497 times.
10318432 for(int32_t i=0; i<guys.Count(); i++)
19751 {
19752
2/2
✓ Branch 0 taken 4122410 times.
✓ Branch 1 taken 3876525 times.
7998935 if(((enemy*)guys.spr(i))->mainguy)
19753 {
19754 4122410 return true;
19755 }
19756 3876525 }
19757
19758 2319497 return false;
19759 6441907 }
19760
19761 51 void EatHero(int32_t index)
19762 {
19763 51 ((eStalfos*)guys.spr(index))->eathero();
19764 51 }
19765
19766 3 void GrabHero(int32_t index)
19767 {
19768 3 ((eWallM*)guys.spr(index))->grabhero();
19769 3 }
19770
19771 292 bool CarryHero()
19772 {
19773
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
19774 {
19775
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
19776 {
19777
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
19778 {
19779 292 Hero.x=guys.spr(i)->x;
19780 292 Hero.y=guys.spr(i)->y;
19781 292 return ((eWallM*)guys.spr(i))->misc > 0;
19782 }
19783 63 }
19784
19785 // Like Likes currently can't carry Hero.
19786 /*
19787 if(((guy*)(guys.spr(i)))->family==eeLIKE)
19788 {
19789 if(((eLikeLike*)guys.spr(i))->hashero)
19790 {
19791 Hero.x=guys.spr(i)->x;
19792 Hero.y=guys.spr(i)->y;
19793 return (true);
19794 }
19795 }*/
19796 599 }
19797
19798 return false;
19799 292 }
19800
19801 // Move item with guy
19802 void movefairy(zfix &x,zfix &y,int32_t misc)
19803 {
19804 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19805
19806 if(i!=-1)
19807 {
19808 x = guys.spr(i)->x;
19809 y = guys.spr(i)->y;
19810 }
19811 }
19812
19813 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19814 void movefairy2(zfix x,zfix y,int32_t misc)
19815 {
19816 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19817
19818 if(i!=-1)
19819 {
19820 guys.spr(i)->x = x;
19821 guys.spr(i)->y = y;
19822 }
19823 }// Move item with guy
19824
19825 32232 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
19826 {
19827 32232 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19828
19829
1/2
✓ Branch 0 taken 32232 times.
✗ Branch 1 not taken.
32232 if(fairy)
19830 {
19831 32232 x = fairy->x;
19832 32232 y = fairy->y;
19833 32232 }
19834 32232 }
19835
19836 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19837 void movefairynew2(zfix x,zfix y, item const &itemfairy)
19838 {
19839 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19840
19841 if(fairy)
19842 {
19843 fairy->x = x;
19844 fairy->y = y;
19845 }
19846 }
19847
19848 void killfairy(int32_t misc)
19849 {
19850 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19851 guys.del(i);
19852 }
19853
19854 int32_t getGuyIndex(const int32_t eid)
19855 {
19856 for(word i = 0; i < guys.Count(); i++)
19857 {
19858 if(guys.spr(i)->getUID() == eid)
19859 return i;
19860 }
19861
19862 return -1;
19863 }
19864
19865 void killfairynew(item const &itemfairy)
19866 {
19867 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19868 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
19869 }
19870
19871 //Should probably change this to return an 'enemy*', null on failure -Em
19872 10988 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
19873 {
19874 10988 return addenemy(x,y,0,id,clk);
19875 }
19876
19877 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
19878 {
19879 868 return addchild(x,y,0,id,clk, parent_scriptUID);
19880 }
19881
19882 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
19883 {
19884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
19885
19886 893 int32_t ret = 0;
19887 893 sprite *e=NULL;
19888 893 al_trace("Adding child\n");
19889
19890
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
19891 {
19892 //Fixme: possible enemy memory leak. (minor)
19893 case eeWALK:
19894
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
19895 16 break;
19896
19897 case eeLEV:
19898 e = new eLeever((zfix)x,(zfix)y,id,clk);
19899 break;
19900
19901 case eeTEK:
19902 e = new eTektite((zfix)x,(zfix)y,id,clk);
19903 break;
19904
19905 case eePEAHAT:
19906 e = new ePeahat((zfix)x,(zfix)y,id,clk);
19907 break;
19908
19909 case eeZORA:
19910 e = new eZora((zfix)x,(zfix)y,id,clk);
19911 break;
19912
19913 case eeGHINI:
19914 e = new eGhini((zfix)x,(zfix)y,id,clk);
19915 break;
19916
19917 case eeKEESE:
19918
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
19919 857 break;
19920
19921 case eeWIZZ:
19922
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
19923 15 break;
19924
19925 case eePROJECTILE:
19926 e = new eProjectile((zfix)x,(zfix)y,id,clk);
19927 break;
19928
19929 case eeWALLM:
19930 e = new eWallM((zfix)x,(zfix)y,id,clk);
19931 break;
19932
19933 case eeAQUA:
19934 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
19935 break;
19936
19937 case eeMOLD:
19938 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19939 break;
19940
19941 case eeMANHAN:
19942
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
19943 1 break;
19944
19945 case eeGLEEOK:
19946 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19947 break;
19948
19949 case eeGHOMA:
19950 e = new eGohma((zfix)x,(zfix)y,id,clk);
19951 break;
19952
19953 case eeLANM:
19954 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
19955 break;
19956
19957 case eeGANON:
19958 e = new eGanon((zfix)x,(zfix)y,id,clk);
19959 break;
19960
19961 case eeFAIRY:
19962 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
19963 break;
19964
19965 case eeFIRE:
19966 e = new eFire((zfix)x,(zfix)y,id,clk);
19967 break;
19968
19969 case eeOTHER:
19970 e = new eOther((zfix)x,(zfix)y,id,clk);
19971 break;
19972
19973
19974 case eeSCRIPT01:
19975 case eeSCRIPT02:
19976 case eeSCRIPT03:
19977 case eeSCRIPT04:
19978 case eeSCRIPT05:
19979 case eeSCRIPT06:
19980 case eeSCRIPT07:
19981 case eeSCRIPT08:
19982 case eeSCRIPT09:
19983 case eeSCRIPT10:
19984 case eeSCRIPT11:
19985 case eeSCRIPT12:
19986 case eeSCRIPT13:
19987 case eeSCRIPT14:
19988 case eeSCRIPT15:
19989 case eeSCRIPT16:
19990 case eeSCRIPT17:
19991 case eeSCRIPT18:
19992 case eeSCRIPT19:
19993 case eeSCRIPT20:
19994 {
19995 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19996 {
19997 e = new eScript((zfix)x,(zfix)y,id,clk);
19998 break;
19999 }
20000 else return 0;
20001 }
20002
20003 case eeFFRIENDLY01:
20004 case eeFFRIENDLY02:
20005 case eeFFRIENDLY03:
20006 case eeFFRIENDLY04:
20007 case eeFFRIENDLY05:
20008 case eeFFRIENDLY06:
20009 case eeFFRIENDLY07:
20010 case eeFFRIENDLY08:
20011 case eeFFRIENDLY09:
20012 case eeFFRIENDLY10:
20013 {
20014 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20015 {
20016 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20017 }
20018 else return 0;
20019
20020 }
20021
20022 case eeSPINTILE:
20023 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20024 break;
20025
20026 // and these enemies use the misc10/misc2 value
20027 case eeROCK:
20028 {
20029 switch(guysbuf[id&0xFFF].misc10)
20030 {
20031 case 1:
20032 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20033 break;
20034
20035 case 0:
20036 default:
20037 e = new eRock((zfix)x,(zfix)y,id,clk);
20038 break;
20039 }
20040
20041 break;
20042 }
20043
20044 case eeTRAP:
20045 {
20046 switch(guysbuf[id&0xFFF].misc2)
20047 {
20048 case 1:
20049 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20050 break;
20051
20052 case 0:
20053 default:
20054 e = new eTrap((zfix)x,(zfix)y,id,clk);
20055 break;
20056 }
20057
20058 break;
20059 }
20060
20061 case eeDONGO:
20062 {
20063 switch(guysbuf[id&0xFFF].misc10)
20064 {
20065 case 1:
20066 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20067 break;
20068
20069 case 0:
20070 default:
20071 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20072 break;
20073 }
20074
20075 break;
20076 }
20077
20078 case eeDIG:
20079 {
20080
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
20081 {
20082 case 1:
20083 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20084 break;
20085
20086 4 case 0:
20087 default:
20088
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20089 4 break;
20090 }
20091
20092 4 break;
20093 }
20094
20095 case eePATRA:
20096 {
20097 switch(guysbuf[id&0xFFF].misc10)
20098 {
20099 case 1:
20100 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20101 {
20102 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20103 break;
20104 }
20105 [[fallthrough]];
20106 case 0:
20107 default:
20108 e = new ePatra((zfix)x,(zfix)y,id,clk);
20109 break;
20110 }
20111
20112 break;
20113 }
20114
20115 case eeGUY:
20116 {
20117 switch(guysbuf[id&0xFFF].misc10)
20118 {
20119 case 1:
20120 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20121 break;
20122
20123 case 0:
20124 default:
20125 e = new eNPC((zfix)x,(zfix)y,id,clk);
20126 break;
20127 }
20128
20129 break;
20130 }
20131
20132 case eeNONE:
20133 if(guysbuf[id&0xFFF].misc10 ==1)
20134 {
20135 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20136 break;
20137 break;
20138 }
20139 [[fallthrough]];
20140 default:
20141
20142 return 0;
20143 }
20144
20145 893 ret++; // Made one enemy.
20146
20147
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
20148 {
20149 e->z = (zfix)z;
20150 }
20151
20152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 ((enemy*)e)->ceiling = (z && canfall(id));
20153 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
20154 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
20155 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
20156 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20157 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20158
20159
20160
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
20161 {
20162 return 0;
20163 }
20164
20165 // add segments of segmented enemies
20166 893 int32_t c=0;
20167
20168
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
20169 {
20170 case eeMOLD:
20171 {
20172 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20173 id &= 0xFFF;
20174
20175 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20176 {
20177 //christ this is messy -DD
20178 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20179
20180 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20181 {
20182 al_trace("Moldorm segment %d could not be created!\n",i+1);
20183
20184 for(int32_t j=0; j<i+1; j++)
20185 guys.del(guys.Count()-1);
20186
20187 return 0;
20188 }
20189
20190 if(i>0)
20191 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20192
20193 ret++;
20194 }
20195
20196 break;
20197 }
20198
20199 case eeLANM:
20200 {
20201 id &= 0xFFF;
20202 int32_t shft = guysbuf[id].misc2;
20203 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20204
20205 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20206 {
20207 al_trace("Lanmola segment 1 could not be created!\n");
20208 guys.del(guys.Count()-1);
20209 return 0;
20210 }
20211
20212 ret++;
20213
20214 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20215 {
20216 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20217 {
20218 al_trace("Lanmola segment %d could not be created!\n",i+1);
20219
20220 for(int32_t j=0; j<i+1; j++)
20221 guys.del(guys.Count()-1);
20222
20223 return 0;
20224 }
20225
20226 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20227 ret++;
20228 }
20229 }
20230 break;
20231
20232 case eeMANHAN:
20233 1 id &= 0xFFF;
20234
20235
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20236 {
20237
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20238 {
20239 al_trace("Manhandla head %d could not be created!\n",i+1);
20240
20241 for(int32_t j=0; j<i+1; j++)
20242 {
20243 guys.del(guys.Count()-1);
20244 }
20245
20246 return 0;
20247 }
20248
20249 4 ret++;
20250 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20251 4 }
20252
20253 1 break;
20254
20255 case eeGLEEOK:
20256 {
20257 id &= 0xFFF;
20258
20259 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20260 {
20261 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20262 {
20263 al_trace("Gleeok head %d could not be created!\n",i+1);
20264
20265 for(int32_t j=0; j<i+1; j++)
20266 {
20267 guys.del(guys.Count()-1);
20268 }
20269
20270 return false;
20271 }
20272
20273 c-=guysbuf[id].misc4;
20274 ret++;
20275 }
20276 }
20277 break;
20278
20279
20280 case eePATRA:
20281 {
20282 id &= 0xFFF;
20283 int32_t outeyes = 0;
20284
20285 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20286 {
20287 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20288 {
20289 al_trace("Patra outer eye %d could not be created!\n",i+1);
20290
20291 for(int32_t j=0; j<i+1; j++)
20292 guys.del(guys.Count()-1);
20293
20294 return 0;
20295 }
20296 else
20297 outeyes++;
20298
20299 ret++;
20300 }
20301
20302 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20303 {
20304 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20305 {
20306 al_trace("Patra inner eye %d could not be created!\n",i+1);
20307
20308 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20309 guys.del(guys.Count()-1);
20310
20311 return 0;
20312 }
20313
20314 ret++;
20315 }
20316
20317 break;
20318 }
20319 }
20320
20321 893 return ret;
20322 893 }
20323
20324 // Returns number of enemies/segments created
20325 43820 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
20326 {
20327 //zprint2("addenemy id is: %d\n", (id&0xFFF));
20328 43820 int32_t realid = id&0xFFF;
20329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43820 times.
43820 if( realid > MAXGUYS )
20330 {
20331 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
20332 return 0;
20333 }
20334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43820 times.
43820 if(id <= 0) return 0;
20335
20336 43820 int32_t ret = 0;
20337 43820 sprite *e=NULL;
20338
20339
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23145 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2388 times.
✓ Branch 6 taken 865 times.
✓ Branch 7 taken 1537 times.
✓ Branch 8 taken 139 times.
✓ Branch 9 taken 4734 times.
✓ Branch 10 taken 2081 times.
✓ Branch 11 taken 2127 times.
✓ Branch 12 taken 469 times.
✓ Branch 13 taken 74 times.
✓ Branch 14 taken 85 times.
✓ Branch 15 taken 57 times.
✓ Branch 16 taken 88 times.
✓ Branch 17 taken 54 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 9 times.
✓ Branch 20 taken 383 times.
✓ Branch 21 taken 231 times.
✓ Branch 22 taken 1785 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 238 times.
✓ Branch 25 taken 843 times.
✓ Branch 26 taken 137 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 55 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 23 times.
43820 switch(guysbuf[id&0xFFF].family)
20340 {
20341 //Fixme: possible enemy memory leak. (minor)
20342 case eeWALK:
20343
3/6
✓ Branch 0 taken 23145 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23145 times.
✗ Branch 5 not taken.
23145 e = new eStalfos((zfix)x,(zfix)y,id,clk);
20344 23145 break;
20345
20346 case eeLEV:
20347
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
20348 1694 break;
20349
20350 case eeTEK:
20351
3/6
✓ Branch 0 taken 2388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2388 times.
✗ Branch 5 not taken.
2388 e = new eTektite((zfix)x,(zfix)y,id,clk);
20352 2388 break;
20353
20354 case eePEAHAT:
20355
3/6
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 865 times.
✗ Branch 5 not taken.
865 e = new ePeahat((zfix)x,(zfix)y,id,clk);
20356 865 break;
20357
20358 case eeZORA:
20359
3/6
✓ Branch 0 taken 1537 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1537 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1537 times.
✗ Branch 5 not taken.
1537 e = new eZora((zfix)x,(zfix)y,id,clk);
20360 1537 break;
20361
20362 case eeGHINI:
20363
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eGhini((zfix)x,(zfix)y,id,clk);
20364 139 break;
20365
20366 case eeKEESE:
20367
3/6
✓ Branch 0 taken 4734 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4734 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4734 times.
✗ Branch 5 not taken.
4734 e = new eKeese((zfix)x,(zfix)y,id,clk);
20368 4734 break;
20369
20370 case eeWIZZ:
20371
3/6
✓ Branch 0 taken 2081 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2081 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2081 times.
✗ Branch 5 not taken.
2081 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
20372 2081 break;
20373
20374 case eePROJECTILE:
20375
3/6
✓ Branch 0 taken 2127 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2127 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2127 times.
✗ Branch 5 not taken.
2127 e = new eProjectile((zfix)x,(zfix)y,id,clk);
20376 2127 break;
20377
20378 case eeWALLM:
20379
3/6
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 469 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 469 times.
✗ Branch 5 not taken.
469 e = new eWallM((zfix)x,(zfix)y,id,clk);
20380 469 break;
20381
20382 case eeAQUA:
20383
3/6
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74 times.
✗ Branch 5 not taken.
74 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
20384 74 break;
20385
20386 case eeMOLD:
20387
6/12
✓ Branch 0 taken 85 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 85 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 85 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 85 times.
✓ Branch 10 taken 85 times.
✗ Branch 11 not taken.
85 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20388 85 break;
20389
20390 case eeMANHAN:
20391
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 e = new eManhandla((zfix)x,(zfix)y,id,clk);
20392 57 break;
20393
20394 case eeGLEEOK:
20395
6/12
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 88 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 88 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 88 times.
✓ Branch 10 taken 88 times.
✗ Branch 11 not taken.
88 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20396 88 break;
20397
20398 case eeGHOMA:
20399
3/6
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
54 e = new eGohma((zfix)x,(zfix)y,id,clk);
20400 54 break;
20401
20402 case eeLANM:
20403
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 239 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
20404 239 break;
20405
20406 case eeGANON:
20407
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 e = new eGanon((zfix)x,(zfix)y,id,clk);
20408 9 break;
20409
20410 case eeFAIRY:
20411
3/6
✓ Branch 0 taken 383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 383 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 383 times.
✗ Branch 5 not taken.
383 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
20412 383 break;
20413
20414 case eeFIRE:
20415
3/6
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 231 times.
✗ Branch 5 not taken.
231 e = new eFire((zfix)x,(zfix)y,id,clk);
20416 231 break;
20417
20418 case eeOTHER:
20419
3/6
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1785 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1785 times.
✗ Branch 5 not taken.
1785 e = new eOther((zfix)x,(zfix)y,id,clk);
20420 1785 break;
20421
20422
20423 case eeSCRIPT01:
20424 case eeSCRIPT02:
20425 case eeSCRIPT03:
20426 case eeSCRIPT04:
20427 case eeSCRIPT05:
20428 case eeSCRIPT06:
20429 case eeSCRIPT07:
20430 case eeSCRIPT08:
20431 case eeSCRIPT09:
20432 case eeSCRIPT10:
20433 case eeSCRIPT11:
20434 case eeSCRIPT12:
20435 case eeSCRIPT13:
20436 case eeSCRIPT14:
20437 case eeSCRIPT15:
20438 case eeSCRIPT16:
20439 case eeSCRIPT17:
20440 case eeSCRIPT18:
20441 case eeSCRIPT19:
20442 case eeSCRIPT20:
20443 {
20444 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20445 {
20446 e = new eScript((zfix)x,(zfix)y,id,clk);
20447 break;
20448 }
20449 else return 0;
20450 }
20451
20452 case eeFFRIENDLY01:
20453 case eeFFRIENDLY02:
20454 case eeFFRIENDLY03:
20455 case eeFFRIENDLY04:
20456 case eeFFRIENDLY05:
20457 case eeFFRIENDLY06:
20458 case eeFFRIENDLY07:
20459 case eeFFRIENDLY08:
20460 case eeFFRIENDLY09:
20461 case eeFFRIENDLY10:
20462 {
20463 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20464 {
20465 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20466 }
20467 else return 0;
20468
20469 }
20470
20471 case eeSPINTILE:
20472
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20473 94 break;
20474
20475 // and these enemies use the misc10/misc2 value
20476 case eeROCK:
20477 {
20478
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 208 times.
238 switch(guysbuf[id&0xFFF].misc10)
20479 {
20480 case 1:
20481
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20482 30 break;
20483
20484 208 case 0:
20485 default:
20486
3/6
✓ Branch 0 taken 208 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 208 times.
✗ Branch 5 not taken.
208 e = new eRock((zfix)x,(zfix)y,id,clk);
20487 208 break;
20488 }
20489
20490 238 break;
20491 }
20492
20493 case eeTRAP:
20494 {
20495
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✓ Branch 2 taken 703 times.
843 switch(guysbuf[id&0xFFF].misc2)
20496 {
20497 case 1:
20498
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20499 140 break;
20500
20501 703 case 0:
20502 default:
20503
3/6
✓ Branch 0 taken 703 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 703 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 703 times.
✗ Branch 5 not taken.
703 e = new eTrap((zfix)x,(zfix)y,id,clk);
20504 703 break;
20505 }
20506
20507 843 break;
20508 }
20509
20510 case eeDONGO:
20511 {
20512
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 135 times.
137 switch(guysbuf[id&0xFFF].misc10)
20513 {
20514 case 1:
20515
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20516 2 break;
20517
20518 135 case 0:
20519 default:
20520
3/6
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
135 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20521 135 break;
20522 }
20523
20524 137 break;
20525 }
20526
20527 case eeDIG:
20528 {
20529
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
20530 {
20531 case 1:
20532
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20533 198 break;
20534
20535 48 case 0:
20536 default:
20537
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20538 48 break;
20539 }
20540
20541 246 break;
20542 }
20543
20544 case eePATRA:
20545 {
20546
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 3 times.
55 switch(guysbuf[id&0xFFF].misc10)
20547 {
20548 case 1:
20549
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20550 {
20551
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20552 3 break;
20553 }
20554 [[fallthrough]];
20555 52 case 0:
20556 default:
20557
3/6
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
52 e = new ePatra((zfix)x,(zfix)y,id,clk);
20558 52 break;
20559 }
20560
20561 55 break;
20562 }
20563
20564 case eeGUY:
20565 {
20566 switch(guysbuf[id&0xFFF].misc10)
20567 {
20568 case 1:
20569 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20570 break;
20571
20572 case 0:
20573 default:
20574 e = new eNPC((zfix)x,(zfix)y,id,clk);
20575 break;
20576 }
20577
20578 break;
20579 }
20580
20581 case eeNONE:
20582
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(guysbuf[id&0xFFF].misc10 ==1)
20583 {
20584
3/6
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
23 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20585 23 break;
20586 break;
20587 }
20588 [[fallthrough]];
20589 default:
20590
20591 return 0;
20592 }
20593
20594 43820 ret++; // Made one enemy.
20595
20596
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 43737 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
43820 if(z && canfall(id))
20597 {
20598 59 e->z = (zfix)z;
20599 59 }
20600
20601
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 43737 times.
43820 ((enemy*)e)->ceiling = (z && canfall(id));
20602
20603
1/2
✓ Branch 0 taken 43820 times.
✗ Branch 1 not taken.
43820 if(!guys.add(e))
20604 {
20605 return 0;
20606 }
20607
20608 // add segments of segmented enemies
20609 43820 int32_t c=0;
20610
20611
6/6
✓ Branch 0 taken 43296 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 88 times.
✓ Branch 5 taken 55 times.
43820 switch(guysbuf[id&0xFFF].family)
20612 {
20613 case eeMOLD:
20614 {
20615 85 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20616 85 id &= 0xFFF;
20617
20618
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 570 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 570 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 570 times.
✓ Branch 6 taken 485 times.
✓ Branch 7 taken 85 times.
570 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20619 {
20620 //christ this is messy -DD
20621 485 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20622
20623
4/8
✓ Branch 0 taken 485 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 485 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 485 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 485 times.
✗ Branch 7 not taken.
485 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20624 {
20625 al_trace("Moldorm segment %d could not be created!\n",i+1);
20626
20627 for(int32_t j=0; j<i+1; j++)
20628 guys.del(guys.Count()-1);
20629
20630 return 0;
20631 }
20632
20633
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 400 times.
485 if(i>0)
20634 400 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20635
20636 485 ret++;
20637 485 }
20638
20639 85 break;
20640 }
20641
20642 case eeLANM:
20643 {
20644 239 id &= 0xFFF;
20645 239 int32_t shft = guysbuf[id].misc2;
20646 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20647
20648
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20649 {
20650 al_trace("Lanmola segment 1 could not be created!\n");
20651 guys.del(guys.Count()-1);
20652 return 0;
20653 }
20654
20655 239 ret++;
20656
20657
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1250 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20658 {
20659
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20660 {
20661 al_trace("Lanmola segment %d could not be created!\n",i+1);
20662
20663 for(int32_t j=0; j<i+1; j++)
20664 guys.del(guys.Count()-1);
20665
20666 return 0;
20667 }
20668
20669 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20670 1011 ret++;
20671 1011 }
20672 }
20673 239 break;
20674
20675 case eeMANHAN:
20676 57 id &= 0xFFF;
20677
20678
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 57 times.
317 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20679 {
20680
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20681 {
20682 al_trace("Manhandla head %d could not be created!\n",i+1);
20683
20684 for(int32_t j=0; j<i+1; j++)
20685 {
20686 guys.del(guys.Count()-1);
20687 }
20688
20689 return 0;
20690 }
20691
20692 260 ret++;
20693 260 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20694 260 }
20695
20696 57 break;
20697
20698 case eeGLEEOK:
20699 {
20700 88 id &= 0xFFF;
20701 88 eGleeok* parent = (eGleeok*)e;
20702
20703
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 347 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 347 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 347 times.
✓ Branch 6 taken 259 times.
✓ Branch 7 taken 88 times.
347 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20704 {
20705
3/6
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 259 times.
✗ Branch 5 not taken.
259 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
20706
1/2
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
259 if(!guys.add(head))
20707 {
20708 al_trace("Gleeok head %d could not be created!\n",i+1);
20709
20710 for(int32_t j=0; j<i+1; j++)
20711 {
20712 guys.del(guys.Count()-1);
20713 }
20714
20715 return false;
20716 }
20717
20718 259 head->necktile=parent->necktile;
20719 259 head->dummy_int[1]=parent->necktile;
20720
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 73 times.
259 if(get_bit(quest_rules,qr_NEWENEMYTILES))
20721 {
20722 186 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
20723 186 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
20724 186 }
20725 else
20726 {
20727 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
20728 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
20729 }
20730 259 head->tile = head->dummy_int[2];
20731
20732 259 c-=guysbuf[id].misc4;
20733 259 ret++;
20734 259 }
20735 }
20736 88 break;
20737
20738
20739 case eePATRA:
20740 {
20741 55 id &= 0xFFF;
20742 55 int32_t outeyes = 0;
20743
20744
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 489 times.
✓ Branch 2 taken 434 times.
✓ Branch 3 taken 55 times.
489 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20745 {
20746
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 416 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 416 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 416 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 416 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
434 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20747 {
20748 al_trace("Patra outer eye %d could not be created!\n",i+1);
20749
20750 for(int32_t j=0; j<i+1; j++)
20751 guys.del(guys.Count()-1);
20752
20753 return 0;
20754 }
20755 else
20756 434 outeyes++;
20757
20758 434 ret++;
20759 434 }
20760
20761
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 55 times.
143 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20762 {
20763
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20764 {
20765 al_trace("Patra inner eye %d could not be created!\n",i+1);
20766
20767 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20768 guys.del(guys.Count()-1);
20769
20770 return 0;
20771 }
20772
20773 88 ret++;
20774 88 }
20775
20776 55 break;
20777 }
20778 }
20779
20780 43820 return ret;
20781 43820 }
20782
20783 809262 bool isjumper(int32_t id)
20784 {
20785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 809262 times.
809262 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20786 {
20787 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
20788 return false;
20789 }
20790
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 733025 times.
✓ Branch 2 taken 76233 times.
809262 switch(guysbuf[id&0xFFF].family)
20791 {
20792 case eeROCK:
20793 case eeTEK:
20794 4 return true;
20795
20796 case eeWALK:
20797
3/4
✓ Branch 0 taken 76233 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 63968 times.
76233 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
20798 63968 }
20799
20800 796993 return false;
20801 809262 }
20802
20803
20804 102707 bool isfixedtogrid(int32_t id)
20805 {
20806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102707 times.
102707 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20807 {
20808 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
20809 return false;
20810 }
20811
1/2
✓ Branch 0 taken 102707 times.
✗ Branch 1 not taken.
102707 switch(guysbuf[id&0xFFF].family)
20812 {
20813 case eeWALK:
20814 case eeLEV:
20815 case eeZORA:
20816 case eeDONGO:
20817 case eeGANON:
20818 case eeROCK:
20819 case eeGLEEOK:
20820 case eeAQUA:
20821 case eeLANM:
20822 return true;
20823 }
20824
20825 102707 return false;
20826 102707 }
20827
20828 // Can't fall, can have Z value.
20829 27499499 bool isflier(int32_t id)
20830 {
20831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27499499 times.
27499499 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20832 {
20833 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
20834 return false;
20835 }
20836
2/2
✓ Branch 0 taken 24475095 times.
✓ Branch 1 taken 3024404 times.
27499499 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
20837 {
20838 case eePEAHAT:
20839 case eeKEESE:
20840 case eePATRA:
20841 case eeFAIRY:
20842 case eeGHINI:
20843
20844 // Could theoretically have their Z set by a script
20845 case eeFIRE:
20846 3024404 return true;
20847 break;
20848 }
20849
20850 24475095 return false;
20851 27499499 }
20852
20853 // Can't have Z position
20854 1383374 bool never_in_air(int32_t id)
20855 {
20856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1383374 times.
1383374 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20857 {
20858 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
20859 return false;
20860 }
20861
2/2
✓ Branch 0 taken 1373826 times.
✓ Branch 1 taken 9548 times.
1383374 switch(guysbuf[id&0xFFF].family)
20862 {
20863 case eeMANHAN:
20864 case eeMOLD:
20865 case eeLANM:
20866 case eeGLEEOK:
20867 case eeZORA:
20868 case eeLEV:
20869 case eeAQUA:
20870 case eeROCK:
20871 case eeGANON:
20872 case eeTRAP:
20873 case eePROJECTILE:
20874 case eeSPINTILE:
20875 9548 return true;
20876 }
20877
20878 1373826 return false;
20879 1383374 }
20880
20881 903030 bool canfall(int32_t id)
20882 {
20883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 903030 times.
903030 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20884 {
20885 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
20886 return false;
20887 }
20888
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 903004 times.
✓ Branch 2 taken 26 times.
903030 switch(guysbuf[id&0xFFF].family)
20889 {
20890 case eeGUY:
20891 {
20892
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
20893 26 return false;
20894
20895 switch(guysbuf[id&0xFFF].misc10)
20896 {
20897 case 1:
20898 case 2:
20899 return true;
20900
20901 case 0:
20902 case 3:
20903 default:
20904 return false;
20905 }
20906
20907 case eeGHOMA:
20908 case eeDIG:
20909 return false;
20910 }
20911 }
20912
20913
20914
4/4
✓ Branch 0 taken 894570 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 85308 times.
✓ Branch 3 taken 809262 times.
903004 return !never_in_air(id) && !isflier(id) && !isjumper(id);
20915 903030 }
20916
20917 27031878 bool enemy::enemycanfall(int32_t id, bool checkgrav)
20918 {
20919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27031878 times.
27031878 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20920 {
20921 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
20922 return false;
20923 }
20924 //Z_scripterrlog("canfall family is %d:\n", family);
20925 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
20926 //if ( family == eeFIRE && id >= eSTART )
20927 //{
20928 // Z_scripterrlog("eeFire\n");
20929 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
20930 //}
20931
20932 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
20933
20934
3/3
✓ Branch 0 taken 194768 times.
✓ Branch 1 taken 26036309 times.
✓ Branch 2 taken 800801 times.
27031878 switch(guysbuf[id&0xFFF].family)
20935 {
20936 case eeGUY:
20937 {
20938
1/2
✓ Branch 0 taken 800801 times.
✗ Branch 1 not taken.
800801 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
20939 800801 return false;
20940
20941 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
20942 {
20943 case 1:
20944 case 2:
20945 return true;
20946
20947 case 0:
20948 case 3:
20949 default:
20950 return false;
20951 }
20952
20953 case eeGHOMA:
20954 case eeDIG:
20955 194768 return false;
20956 }
20957 }
20958
20959
2/2
✓ Branch 0 taken 19790577 times.
✓ Branch 1 taken 6245732 times.
26036309 if(!checkgrav) return true;
20960 19790577 return (moveflags & FLAG_OBEYS_GRAV);
20961
20962 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
20963 // {
20964 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
20965 // else return false;
20966 // }
20967 // else
20968 // {
20969 // return (moveflags & FLAG_OBEYS_GRAV);
20970 // }
20971 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
20972 27031878 }
20973
20974 608 void addfires()
20975 {
20976
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 272 times.
608 if(!get_bit(quest_rules,qr_NOGUYFIRES))
20977 {
20978 336 int32_t bs = get_bit(quest_rules,qr_BSZELDA);
20979 336 addguy(bs? 64: 72,64,gFIRE,-17,false);
20980 336 addguy(bs?176:168,64,gFIRE,-18,false);
20981 336 }
20982 608 }
20983
20984 13411 void loadguys()
20985 {
20986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13411 times.
13411 if(loaded_guys)
20987 return;
20988
20989 13411 loaded_guys=true;
20990
20991 13411 byte Guy=0;
20992 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
20993 // Else use mITEM and ipONETIME
20994 13411 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
20995 13411 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
20996
20997 13411 repaircharge=0;
20998 13411 adjustmagic=false;
20999 13411 learnslash=false;
21000
21001
2/2
✓ Branch 0 taken 40239 times.
✓ Branch 1 taken 13411 times.
53650 for(int32_t i=0; i<3; i++)
21002 {
21003 40239 prices[i]=0;
21004 40239 }
21005
21006 13411 hasitem=0;
21007
21008
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 12732 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
13411 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
21009 {
21010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
21011 {
21012 339 Guy=tmpscr[1].guy;
21013 339 }
21014 339 }
21015 else
21016 {
21017 13072 Guy=tmpscr->guy;
21018
21019
4/4
✓ Branch 0 taken 12734 times.
✓ Branch 1 taken 338 times.
✓ Branch 2 taken 7613 times.
✓ Branch 3 taken 5121 times.
13072 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
21020 5121 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
21021 }
21022
21023 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
21024
4/4
✓ Branch 0 taken 2708 times.
✓ Branch 1 taken 10703 times.
✓ Branch 2 taken 2083 times.
✓ Branch 3 taken 625 times.
13411 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
21025 {
21026
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 616 times.
625 if(tmpscr->room==rZELDA)
21027 {
21028 9 addguy(120,72,Guy,-15,true);
21029 9 guys.spr(0)->hxofs=1000;
21030 9 addenemy(128,96,eFIRE,-15);
21031 9 addenemy(112,96,eFIRE,-15);
21032 9 addenemy(96,120,eFIRE,-15);
21033 9 addenemy(144,120,eFIRE,-15);
21034 9 return;
21035 }
21036
21037
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 606 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 2 times.
616 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21038 608 addfires();
21039
21040
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 335 times.
620 if(currscr>=128)
21041
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
21042 12 Guy=0;
21043
21044
4/6
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 511 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
620 switch(tmpscr->room)
21045 {
21046 case rSP_ITEM:
21047 case rGRUMBLE:
21048 case rBOMBS:
21049 case rARROWS:
21050 case rSWINDLE:
21051 case rMUPGRADE:
21052 case rLEARNSLASH:
21053 case rTAKEONE:
21054
8/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 45 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
85 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21055 27 Guy=0;
21056
21057 125 break;
21058
21059 case rREPAIR:
21060 if (get_bit(quest_rules, qr_OLD_DOORREPAIR)) break;
21061 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21062 Guy=0;
21063
21064 break;
21065 case rRP_HC:
21066 if (get_bit(quest_rules, qr_OLD_POTION_OR_HC)) break;
21067 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21068 Guy=0;
21069
21070 break;
21071 case rMONEY:
21072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (get_bit(quest_rules, qr_OLD_SECRETMONEY)) break;
21073 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21074 Guy=0;
21075
21076 break;
21077
21078 case rTRIFORCE:
21079 {
21080 23 int32_t tc = TriforceCount();
21081
21082
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 11 times.
23 if(get_bit(quest_rules,qr_4TRI))
21083 {
21084
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=3) || tc>=4)
21085 10 Guy=0;
21086 9 }
21087 else
21088 {
21089
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_bit(quest_rules,qr_3TRI) && tc>=6) || tc>=8)
21090 12 Guy=0;
21091 }
21092 }
21093 21 break;
21094 }
21095
21096
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 559 times.
618 if(Guy)
21097 {
21098
3/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 549 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
559 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21099 549 blockpath=true;
21100
21101
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 236 times.
559 if(currscr<128)
21102 236 sfx(WAV_SCALE);
21103
21104
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
559 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true);
21105 559 Hero.Freeze();
21106 559 }
21107 618 }
21108
2/2
✓ Branch 0 taken 12735 times.
✓ Branch 1 taken 51 times.
12786 else if(Guy==gFAIRY) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
21109 {
21110 51 sfx(WAV_SCALE);
21111 51 addguy(120,62,gFAIRY,-14,false);
21112 51 }
21113
21114 13404 loaditem();
21115
21116 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
21117 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
21118
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 13395 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 7 times.
13404 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
21119 {
21120 //setmapflag();
21121
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 7 times.
77 for(int32_t i=0; i<10; i++)
21122 70 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
21123 7 }
21124 13413 }
21125
21126 13417 void loaditem()
21127 {
21128 13417 byte Item = 0;
21129
21130
2/2
✓ Branch 0 taken 12738 times.
✓ Branch 1 taken 679 times.
13417 if(currscr<128)
21131 {
21132 12738 Item=tmpscr->item;
21133
21134
4/4
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 12123 times.
✓ Branch 2 taken 11483 times.
✓ Branch 3 taken 1255 times.
12738 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21135 {
21136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
1255 if(tmpscr->flags8&fSECRETITEM)
21137 hasitem=8;
21138
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 645 times.
1255 else if(tmpscr->flags&fITEM)
21139 610 hasitem=1;
21140
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 616 times.
645 else if(tmpscr->enemyflags&efCARRYITEM)
21141 29 hasitem=4; // Will be set to 2 by roaming_item
21142 else
21143
2/4
✓ Branch 0 taken 616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 616 times.
✗ Branch 3 not taken.
1232 items.add(new item((zfix)tmpscr->itemx,
21144
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 616 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 616 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 616 times.
✗ Branch 13 not taken.
616 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21145
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 613 times.
✗ Branch 9 not taken.
616 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21146
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 556 times.
616 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21147 616 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21148 1255 }
21149 12738 }
21150
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
21151 {
21152
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
21153
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_bit(quest_rules,qr_ITEMSINPASSAGEWAYS)))
21154 {
21155 110 Item=tmpscr[1].catchall;
21156
21157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
21158
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
21159
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 110 times.
✗ Branch 13 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21160
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21161 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21162 110 }
21163 340 }
21164 13417 }
21165
21166 519 void never_return(int32_t index)
21167 {
21168
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 129 times.
519 if(!get_bit(quest_rules,qr_KILLALL))
21169 129 goto doit;
21170
21171
2/2
✓ Branch 0 taken 1313 times.
✓ Branch 1 taken 191 times.
1504 for(int32_t i=0; i<guys.Count(); i++)
21172
4/4
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 823 times.
✓ Branch 2 taken 199 times.
✓ Branch 3 taken 291 times.
1313 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
21173 {
21174 199 goto dontdoit;
21175 191 }
21176
21177 doit:
21178 320 setmapflag(mNEVERRET);
21179 dontdoit:
21180 519 return;
21181 }
21182
21183 31222 bool slowguy(int32_t id)
21184 {
21185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31222 times.
31222 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21186 {
21187 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
21188 return false;
21189 }
21190 //return (guysbuf[id].step<100);
21191
2/2
✓ Branch 0 taken 26299 times.
✓ Branch 1 taken 4923 times.
31222 switch(id)
21192 {
21193 case eOCTO1S:
21194 case eOCTO2S:
21195 case eOCTO1F:
21196 case eOCTO2F:
21197 case eLEV1:
21198 case eLEV2:
21199 case eROCK:
21200 case eBOULDER:
21201 4923 return true;
21202 }
21203
21204 26299 return false;
21205 31222 }
21206
21207 34865 bool ok2add(int32_t id)
21208 {
21209
2/4
✓ Branch 0 taken 34865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34865 times.
34865 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
21210 {
21211 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
21212 return false;
21213 }
21214
4/4
✓ Branch 0 taken 374 times.
✓ Branch 1 taken 34491 times.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 204 times.
34865 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
21215 204 return false;
21216
21217
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34537 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 92 times.
34661 switch(guysbuf[id].family)
21218 {
21219 // I added a special case for shooters because having traps on the same screen
21220 // was preventing them from spawning due to TMPNORET. This means they will
21221 // never stay dead, though, so it may not be the best solution. - Saf
21222 case eePROJECTILE:
21223 32 return true;
21224
21225
21226 case eeDIG:
21227 {
21228
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
21229 {
21230 case 1:
21231
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_bit(quest_rules,qr_NOTMPNORET))
21232 13 return !getmapflag(mTMPNORET);
21233
21234 32 return true;
21235
21236 47 case 0:
21237 default:
21238 47 return true;
21239 }
21240 }
21241 case eeGANON:
21242 case eeTRAP:
21243 if ((guysbuf[id].family == eeGANON && !get_bit(quest_rules, qr_CAN_PLACE_GANON))
21244 || (guysbuf[id].family == eeTRAP && !get_bit(quest_rules, qr_CAN_PLACE_TRAPS))) return false;
21245 [[fallthrough]];
21246 default:
21247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34537 times.
34537 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
21248 34537 break;
21249 }
21250
21251
2/2
✓ Branch 0 taken 12330 times.
✓ Branch 1 taken 22207 times.
34537 if(!get_bit(quest_rules,qr_NOTMPNORET))
21252 22207 return !getmapflag(mTMPNORET);
21253
21254 12330 return true;
21255 34865 }
21256
21257 263502 void activate_fireball_statue(int32_t pos)
21258 {
21259
3/4
✓ Branch 0 taken 100614 times.
✓ Branch 1 taken 162888 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100614 times.
263502 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
21260 {
21261 162888 return;
21262 }
21263
21264 100614 int32_t cx=-1000, cy=-1000;
21265 100614 int32_t x = (pos&15)<<4;
21266 100614 int32_t y = pos&0xF0;
21267
21268 100614 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21269
21270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100614 times.
100614 if(!isfixedtogrid(statueID))
21271 {
21272
2/2
✓ Branch 0 taken 996 times.
✓ Branch 1 taken 99618 times.
100614 if(ctype==cL_STATUE)
21273 {
21274 996 cx=x+4;
21275 996 cy=y+7;
21276 996 }
21277
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 98603 times.
99618 else if(ctype==cR_STATUE)
21278 {
21279 1015 cx=x-8;
21280 1015 cy=y-1;
21281 1015 }
21282
2/2
✓ Branch 0 taken 98521 times.
✓ Branch 1 taken 82 times.
98603 else if(ctype==cC_STATUE)
21283 {
21284 82 cx=x;
21285 82 cy=y;
21286 82 }
21287 100614 }
21288 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
21289 {
21290 cx=x;
21291 cy=y;
21292 }
21293
21294
2/2
✓ Branch 0 taken 98521 times.
✓ Branch 1 taken 2093 times.
100614 if(cx!=-1000) // No point creating it if this is false
21295 {
21296
2/2
✓ Branch 0 taken 6177 times.
✓ Branch 1 taken 2093 times.
8270 for(int32_t j=0; j<guys.Count(); j++)
21297 {
21298
3/4
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 5013 times.
✓ Branch 2 taken 1164 times.
✗ Branch 3 not taken.
6177 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
21299 {
21300 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
21301 return; // No point deleting it. A script might be toying with it in some way.
21302 else
21303 guys.del(j);
21304 }
21305 6177 }
21306
21307 2093 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
21308 2093 }
21309 263502 }
21310
21311 13329 void activate_fireball_statues()
21312 {
21313
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 12772 times.
13329 if(!(tmpscr->enemyflags&efFIREBALLS))
21314 {
21315 12772 return;
21316 }
21317
21318
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 98032 times.
98589 for(int32_t i=0; i<176; i++)
21319 {
21320 98032 activate_fireball_statue(i);
21321 98032 }
21322 13329 }
21323
21324 13329 void load_default_enemies()
21325 {
21326 13329 wallm_load_clk=frame-80;
21327
21328
2/2
✓ Branch 0 taken 12364 times.
✓ Branch 1 taken 965 times.
13329 if(tmpscr->enemyflags&efZORA)
21329 {
21330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(zoraID>=0)
21331 965 addenemy(-16, -16, zoraID, 0);
21332 965 }
21333
21334
2/2
✓ Branch 0 taken 13226 times.
✓ Branch 1 taken 103 times.
13329 if(tmpscr->enemyflags&efTRAP4)
21335 {
21336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
21337 {
21338 103 addenemy(32, 32, cornerTrapID, -14);
21339 103 addenemy(208, 32, cornerTrapID, -14);
21340 103 addenemy(32, 128, cornerTrapID, -14);
21341 103 addenemy(208, 128, cornerTrapID, -14);
21342 103 }
21343 103 }
21344
21345
2/2
✓ Branch 0 taken 146619 times.
✓ Branch 1 taken 13329 times.
159948 for(int32_t y=0; y<176; y+=16)
21346 {
21347
2/2
✓ Branch 0 taken 2345904 times.
✓ Branch 1 taken 146619 times.
2492523 for(int32_t x=0; x<256; x+=16)
21348 {
21349 2345904 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21350 2345904 int32_t cflag = MAPFLAG(x, y);
21351 2345904 int32_t cflag_i = MAPCOMBOFLAG(x, y);
21352
21353
4/6
✓ Branch 0 taken 2345904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345846 times.
✓ Branch 3 taken 58 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345846 times.
2345904 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
21354 {
21355
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 48 times.
58 if(trapLOSHorizontalID>=0)
21356 48 addenemy(x, y, trapLOSHorizontalID, -14);
21357 58 }
21358
4/6
✓ Branch 0 taken 2345846 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345822 times.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345822 times.
2345846 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
21359 {
21360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(trapLOSVerticalID>=0)
21361 24 addenemy(x, y, trapLOSVerticalID, -14);
21362 24 }
21363
4/6
✓ Branch 0 taken 2345822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345683 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345683 times.
2345822 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
21364 {
21365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(trapLOS4WayID>=0)
21366 {
21367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(addenemy(x, y, trapLOS4WayID, -14))
21368 139 guys.spr(guys.Count()-1)->dummy_int[1]=2;
21369 139 }
21370 139 }
21371
21372
4/6
✓ Branch 0 taken 2345683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345623 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345623 times.
2345683 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
21373 {
21374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if(trapConstantHorizontalID>=0)
21375 60 addenemy(x, y, trapConstantHorizontalID, -14);
21376 60 }
21377
4/6
✓ Branch 0 taken 2345623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2345543 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2345543 times.
2345623 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
21378 {
21379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
21380 80 addenemy(x, y, trapConstantVerticalID, -14);
21381 80 }
21382
21383
1/2
✓ Branch 0 taken 2345904 times.
✗ Branch 1 not taken.
2345904 if(ctype==cSPINTILE1)
21384 {
21385 // Awaken spinning tile
21386 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
21387 }
21388 2345904 }
21389 146619 }
21390
21391
2/2
✓ Branch 0 taken 13287 times.
✓ Branch 1 taken 42 times.
13329 if(tmpscr->enemyflags&efTRAP2)
21392 {
21393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(centerTrapID>=-1)
21394 {
21395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(addenemy(64, 80, centerTrapID, -14))
21396 42 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21397
21398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(addenemy(176, 80, centerTrapID, -14))
21399 42 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21400 42 }
21401 42 }
21402
21403
2/2
✓ Branch 0 taken 13268 times.
✓ Branch 1 taken 61 times.
13329 if(tmpscr->enemyflags&efROCKS)
21404 {
21405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(rockID>=0)
21406 {
21407 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21408 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21409 61 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21410 61 }
21411 61 }
21412
21413 13329 activate_fireball_statues();
21414 13329 }
21415
21416 16643690 void update_slope_combopos(int32_t lyr, int32_t pos)
21417 {
21418
2/4
✓ Branch 0 taken 16643690 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16643690 times.
16643690 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
21419 16643690 mapscr* s = FFCore.tempScreens[lyr];
21420 16643690 newcombo const& cmb = combobuf[s->data[pos]];
21421
21422 16643690 auto id = (176*lyr)+pos;
21423 16643690 auto it = slopes.find(id);
21424
21425 16643690 bool wasSlope = it!=slopes.end();
21426 16643690 bool isSlope = cmb.type == cSLOPE;
21427
21428
3/4
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 16643507 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 183 times.
16643690 if(isSlope && !wasSlope)
21429 {
21430 183 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
21431 183 }
21432
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16643507 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16643507 else if(wasSlope && !isSlope)
21433 {
21434 slopes.erase(it);
21435 }
21436 16643690 }
21437 13426 void update_slope_comboposes()
21438 {
21439
2/2
✓ Branch 0 taken 93982 times.
✓ Branch 1 taken 13426 times.
107408 for(auto lyr = 0; lyr < 7; ++lyr)
21440 {
21441
2/2
✓ Branch 0 taken 16540832 times.
✓ Branch 1 taken 93982 times.
16634814 for(auto pos = 0; pos < 176; ++pos)
21442 16540832 update_slope_combopos(lyr,pos);
21443 93982 }
21444 13426 }
21445
21446 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
21447 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
21448 165470 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
21449 {
21450 165470 delete_fireball_shooter(s, pos);
21451 165470 }
21452
21453 //Placeholder in case we need it.
21454 void screen_ffc_modify_preroutine(word index)
21455 {
21456 return;
21457 }
21458
21459 // Everything that must be done after we change a screen's combo to another combo. -L
21460 165470 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
21461 {
21462 165470 s->valid |= mVALID;
21463 165470 activate_fireball_statue(pos);
21464
21465
2/2
✓ Branch 0 taken 165376 times.
✓ Branch 1 taken 94 times.
165470 if(combobuf[s->data[pos]].type==cSPINTILE1)
21466 {
21467 // Awaken spinning tile
21468 94 awaken_spinning_tile(s,pos);
21469 94 }
21470 165470 int32_t lyr = -1;
21471
2/2
✓ Branch 0 taken 88199 times.
✓ Branch 1 taken 77271 times.
165470 if(s == tmpscr) lyr = 0;
21472
2/2
✓ Branch 0 taken 62612 times.
✓ Branch 1 taken 469914 times.
532526 else for(size_t q = 0; q < 6; ++q)
21473 {
21474
2/2
✓ Branch 0 taken 25587 times.
✓ Branch 1 taken 444327 times.
469914 if(s == tmpscr2+q)
21475 {
21476 25587 lyr = q+1;
21477 25587 break;
21478 }
21479 444327 }
21480
2/2
✓ Branch 0 taken 62612 times.
✓ Branch 1 taken 102858 times.
165470 if(lyr > -1)
21481 102858 update_slope_combopos(lyr,pos);
21482 165470 }
21483
21484 2822535 void screen_ffc_modify_postroutine(word index)
21485 {
21486 2822535 ffcdata& ff = tmpscr->ffcs[index];
21487 2822535 newcombo const& cmb = combobuf[ff.getData()];
21488
21489 2822535 auto id = (176*7)+int32_t(index);
21490 2822535 auto it = slopes.find(id);
21491
21492 2822535 bool wasSlope = it!=slopes.end();
21493
2/2
✓ Branch 0 taken 2822180 times.
✓ Branch 1 taken 355 times.
2822535 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
21494
3/4
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 2822194 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
2822535 if(isSlope && !wasSlope)
21495 {
21496 341 slopes.try_emplace(id, nullptr, &ff, id);
21497 341 }
21498
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2822193 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2822194 else if(wasSlope && !isSlope)
21499 {
21500 1 slopes.erase(it);
21501 1 }
21502
21503 2822535 tmpscr->ffcCountMarkDirty();
21504 2822535 }
21505
21506 1080 void screen_combo_modify_pre(int32_t cid)
21507 {
21508
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 1080 times.
8640 for(auto lyr = 0; lyr < 7; ++lyr)
21509 {
21510 7560 mapscr* t = FFCore.tempScreens[lyr];
21511
2/2
✓ Branch 0 taken 1330560 times.
✓ Branch 1 taken 7560 times.
1338120 for(int32_t i = 0; i < 176; i++)
21512 {
21513
2/2
✓ Branch 0 taken 1329640 times.
✓ Branch 1 taken 920 times.
1330560 if(t->data[i] == cid)
21514 {
21515 920 screen_combo_modify_preroutine(t,i);
21516 920 }
21517 1330560 }
21518 7560 }
21519 1080 }
21520 1080 void screen_combo_modify_post(int32_t cid)
21521 {
21522
2/2
✓ Branch 0 taken 7560 times.
✓ Branch 1 taken 1080 times.
8640 for(auto lyr = 0; lyr < 7; ++lyr)
21523 {
21524 7560 mapscr* t = FFCore.tempScreens[lyr];
21525
2/2
✓ Branch 0 taken 1330560 times.
✓ Branch 1 taken 7560 times.
1338120 for(int32_t i = 0; i < 176; i++)
21526 {
21527
2/2
✓ Branch 0 taken 1329640 times.
✓ Branch 1 taken 920 times.
1330560 if(t->data[i] == cid)
21528 {
21529 920 screen_combo_modify_postroutine(t,i);
21530 920 }
21531 1330560 }
21532 7560 }
21533
2/2
✓ Branch 0 taken 138240 times.
✓ Branch 1 taken 1080 times.
139320 for(word ind = 0; ind < MAXFFCS; ++ind)
21534 {
21535
1/2
✓ Branch 0 taken 138240 times.
✗ Branch 1 not taken.
138240 if(tmpscr->ffcs[ind].getData() == cid)
21536 screen_ffc_modify_postroutine(ind);
21537 138240 }
21538 1080 }
21539
21540 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
21541 {
21542
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
21543 94 }
21544
21545
21546 // It stands for next_side_pos
21547 9987 void nsp(bool random)
21548 // moves sle_x and sle_y to the next position
21549 {
21550
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
21551 {
21552
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
21553 {
21554 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
21555 1634 sle_y = (zc_oldrand()%10)*16;
21556 1634 }
21557 else
21558 {
21559 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
21560 1627 sle_x = (zc_oldrand()%15)*16;
21561 }
21562
21563 3261 return;
21564 }
21565
21566
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
21567 {
21568
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
21569 1496 sle_y+=16;
21570 else
21571 146 sle_x+=16;
21572 1642 }
21573
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
21574 {
21575
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
21576 1985 sle_x+=16;
21577 else
21578 137 sle_y-=16;
21579 2122 }
21580
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
21581 {
21582
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
21583 1165 sle_y-=16;
21584 else
21585 123 sle_x-=16;
21586 1288 }
21587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
21588 {
21589
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
21590 1674 sle_x-=16;
21591 else
21592 sle_y+=16;
21593 1674 }
21594 9987 }
21595
21596 1932 int32_t next_side_pos(bool random)
21597 // moves sle_x and sle_y to the next available position
21598 // returns the direction the enemy should face
21599 {
21600 bool blocked;
21601 1932 int32_t c=0;
21602
21603 1932 do
21604 {
21605
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
21606
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
21607
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
21608
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
21609
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
21610 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
21611
21612
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
21613 1 return -1;
21614
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
21615 9986 while(blocked);
21616
21617 1931 int32_t dir=0;
21618
21619
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
21620
21621
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
21622
21623
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
21624
21625
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
21626
21627 1931 return dir;
21628 1932 }
21629
21630 bool can_side_load(int32_t id)
21631 {
21632 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21633 {
21634 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
21635 return false;
21636 }
21637 switch(guysbuf[id].family) //id&0x0FFF)
21638 {
21639 //case eTEK1:
21640 //case eTEK2:
21641 //case eTEK3:
21642 //case eLEV1:
21643 //case eLEV2:
21644 //case eLEV3:
21645 //case eRAQUAM:
21646 //case eLAQUAM:
21647 //case eDODONGO:
21648 //case eMANHAN:
21649 //case eGLEEOK1:
21650 //case eGLEEOK2:
21651 //case eGLEEOK3:
21652 //case eGLEEOK4:
21653 //case eDIG1:
21654 //case eDIG3:
21655 //case eGOHMA1:
21656 //case eGOHMA2:
21657 //case eCENT1:
21658 //case eCENT2:
21659 //case ePATRA1:
21660 //case ePATRA2:
21661 //case eGANON:
21662 //case eMANHAN2:
21663 //case eCEILINGM: later
21664 //case eFLOORM: later
21665 //case ePATRABS:
21666 //case ePATRAL2:
21667 //case ePATRAL3:
21668 //case eGLEEOK1F:
21669 //case eGLEEOK2F:
21670 //case eGLEEOK3F:
21671 //case eGLEEOK4F:
21672 //case eDODONGOBS:
21673 //case eDODONGOF:
21674 //case eGOHMA3:
21675 //case eGOHMA4:
21676 //case eSHOOTMAGIC:
21677 //case eSHOOTROCK:
21678 //case eSHOOTSPEAR:
21679 //case eSHOOTSWORD:
21680 //case eSHOOTFLAME:
21681 //case eSHOOTFLAME2:
21682 //case eSHOOTFBALL:
21683 case eeTEK:
21684 case eeLEV:
21685 case eeAQUA:
21686 case eeDONGO:
21687 case eeMANHAN:
21688 case eeGLEEOK:
21689 case eeDIG:
21690 case eeGHOMA:
21691 case eeLANM:
21692 case eePATRA:
21693 case eeGANON:
21694 case eePROJECTILE:
21695 return false;
21696 break;
21697 }
21698
21699 return true;
21700 }
21701
21702 static bool script_sle = false;
21703 static int32_t sle_pattern = 0;
21704 void script_side_load_enemies()
21705 {
21706 if(script_sle || sle_clk) return;
21707 sle_cnt = 0;
21708 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21709 ++sle_cnt;
21710 script_sle = true;
21711 sle_pattern = tmpscr->pattern;
21712 sle_clk = 0;
21713 }
21714
21715 42952 void side_load_enemies()
21716 {
21717
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
21718 {
21719 578 sle_pattern = tmpscr->pattern;
21720 578 sle_cnt = 0;
21721 578 int32_t guycnt = 0;
21722 578 int16_t s = (currmap<<7)+currscr;
21723 578 bool beenhere=false;
21724 578 bool reload=true;
21725 578 bool unbeatablereload = true;
21726
21727 578 load_default_enemies();
21728
21729
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
21730
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
21731 178 beenhere=true;
21732
21733
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
21734 {
21735 400 visited[vhead]=s;
21736 400 vhead = (vhead+1)%6;
21737 400 }
21738
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
21739 {
21740 39 sle_cnt=0;
21741 39 reload=false;
21742 39 }
21743
21744
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 193 times.
578 if(reload)
21745 {
21746 193 sle_cnt = game->guys[s];
21747
21748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 193 times.
193 if((get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
21749
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 177 times.
193 || sle_cnt==0)
21750 {
21751
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21752 806 ++sle_cnt;
21753 177 }
21754
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 400 times.
539 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
21755 {
21756 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
21757 {
21758 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
21759 {
21760 unbeatablereload = false;
21761 }
21762 }
21763 if (unbeatablereload)
21764 {
21765 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21766 {
21767 ++sle_cnt;
21768 }
21769 }
21770 }
21771 539 }
21772
21773
4/4
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 346 times.
✓ Branch 2 taken 346 times.
✓ Branch 3 taken 232 times.
924 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
21774 {
21775 692 sle_cnt = 0;
21776
21777
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
692 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21778 ++sle_cnt;
21779 }
21780
21781
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 232 times.
2121 for(int32_t i=0; i<sle_cnt; i++)
21782 1889 ++guycnt;
21783
21784 232 game->guys[s] = guycnt;
21785 232 }
21786
21787
2/2
✓ Branch 0 taken 40674 times.
✓ Branch 1 taken 1932 times.
42606 if((++sle_clk+8)%24 == 0)
21788 {
21789 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
21790
21791
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
21792 {
21793 193 return;
21794 }
21795
21796 1739 int32_t enemy_slot=guys.Count();
21797
21798
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
21799 sle_cnt--;
21800
21801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
21802 {
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
21804 {
21805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
21806 {
21807 1739 guys.spr(enemy_slot)->dir = dir;
21808 1739 }
21809 1739 }
21810 1739 }
21811 1739 }
21812
21813
2/2
✓ Branch 0 taken 41902 times.
✓ Branch 1 taken 511 times.
42413 if(sle_cnt<=0)
21814 {
21815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
21816 script_sle = false;
21817 511 else loaded_enemies=true;
21818 511 sle_clk = 0;
21819 511 }
21820 42606 }
21821
21822 1116657 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
21823 {
21824
21825
4/4
✓ Branch 0 taken 1016793 times.
✓ Branch 1 taken 99864 times.
✓ Branch 2 taken 99864 times.
✓ Branch 3 taken 1116657 times.
1116657 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
21826 {
21827 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
21828 199728 return false; //never 0, never OoB.
21829 }
21830 // No corner enemies
21831
6/6
✓ Branch 0 taken 955765 times.
✓ Branch 1 taken 160892 times.
✓ Branch 2 taken 38836 times.
✓ Branch 3 taken 994601 times.
✓ Branch 4 taken 110960 times.
✓ Branch 5 taken 88768 times.
1116657 if((x==0 || x==240) && (y==0 || y==160))
21832
21833 199728 return false;
21834
21835 //Is a no spawn combo...
21836
3/4
✓ Branch 0 taken 994597 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 994597 times.
994601 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
21837 4 return false;
21838
21839 // No enemies in dungeon walls
21840
10/10
✓ Branch 0 taken 632680 times.
✓ Branch 1 taken 361917 times.
✓ Branch 2 taken 561160 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489640 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403816 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 317992 times.
994597 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
21841 314688 return false;
21842
21843 // Too close
21844
4/4
✓ Branch 0 taken 69555 times.
✓ Branch 1 taken 610354 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 69545 times.
679909 if(tooclose(x,y,40) && t<11)
21845 69545 return false;
21846
21847 // Can't fly onto it?
21848
4/4
✓ Branch 0 taken 114598 times.
✓ Branch 1 taken 495766 times.
✓ Branch 2 taken 34151 times.
✓ Branch 3 taken 16220 times.
660735 if(isflier(tmpscr->enemy[i])&&
21849
2/2
✓ Branch 0 taken 114380 times.
✓ Branch 1 taken 218 times.
114598 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
21850
2/2
✓ Branch 0 taken 50371 times.
✓ Branch 1 taken 64009 times.
114380 (_walkflag(x,y+8,2)&&!get_bit(quest_rules,qr_WALLFLIERS))))
21851 16438 return false;
21852
21853 // Can't jump onto it?
21854 if
21855 (
21856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84201 times.
678127 guysbuf[tmpscr->enemy[i]].family==eeTEK
21857
21858
2/2
✓ Branch 0 taken 84201 times.
✓ Branch 1 taken 509725 times.
593926 &&
21859 (
21860
1/2
✓ Branch 0 taken 84201 times.
✗ Branch 1 not taken.
84201 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
21861
1/2
✓ Branch 0 taken 84201 times.
✗ Branch 1 not taken.
84201 COMBOTYPE(x+8,y+8)==cNOENEMY||
21862
1/2
✓ Branch 0 taken 84201 times.
✗ Branch 1 not taken.
84201 ispitfall(x+8,y+8)||
21863
1/2
✓ Branch 0 taken 84201 times.
✗ Branch 1 not taken.
84201 MAPFLAG(x+8,y+8)==mfNOENEMY||
21864 84201 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
21865 )
21866 )
21867 {
21868 return false;
21869 }
21870
21871 // Other off-limit combos
21872
6/6
✓ Branch 0 taken 495766 times.
✓ Branch 1 taken 98160 times.
✓ Branch 2 taken 411565 times.
✓ Branch 3 taken 84201 times.
✓ Branch 4 taken 237905 times.
✓ Branch 5 taken 173660 times.
1005491 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
21873
2/2
✓ Branch 0 taken 241498 times.
✓ Branch 1 taken 170067 times.
411565 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
21874 411565 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
21875 173660 return false;
21876
21877 // Don't ever generate enemies on these combos!
21878
3/4
✓ Branch 0 taken 419967 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 419967 times.
420266 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
21879 299 return false;
21880
21881 //BS Dodongos need at least 2 spaces.
21882
4/4
✓ Branch 0 taken 960 times.
✓ Branch 1 taken 419007 times.
✓ Branch 2 taken 958 times.
✓ Branch 3 taken 2 times.
419967 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
21883 {
21884
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
21885 ((x>224)||_walkflag(x+16,y+8, 2))&&
21886 ((y<16) ||_walkflag(x, y-8, 2))&&
21887 ((y>144)||_walkflag(x, y+24,2)))
21888 {
21889 return false;
21890 }
21891 2 }
21892
21893 419967 return true;
21894 1016793 }
21895
21896 65664 bool is_ceiling_pattern(int32_t i)
21897 {
21898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65664 times.
65664 return (i==pCEILING || i==pCEILINGR);
21899 }
21900
21901 5548 int32_t placeenemy(int32_t i)
21902 {
21903 5548 std::map<int32_t, int32_t> freeposcache;
21904 5548 int32_t frees = 0;
21905
21906
2/2
✓ Branch 0 taken 61028 times.
✓ Branch 1 taken 5548 times.
66576 for(int32_t y=0; y<176; y+=16)
21907 {
21908
2/2
✓ Branch 0 taken 976448 times.
✓ Branch 1 taken 61028 times.
1037476 for(int32_t x=0; x<256; x+=16)
21909 {
21910
3/4
✓ Branch 0 taken 976448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 394286 times.
✓ Branch 3 taken 582162 times.
976448 if(is_starting_pos(i,x,y,0))
21911 {
21912
1/2
✓ Branch 0 taken 394286 times.
✗ Branch 1 not taken.
394286 freeposcache[frees++] = (y&0xF0)+(x>>4);
21913 394286 }
21914 976448 }
21915 61028 }
21916
21917
2/2
✓ Branch 0 taken 5541 times.
✓ Branch 1 taken 7 times.
5548 if(frees > 0)
21918
2/4
✓ Branch 0 taken 5541 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5541 times.
✗ Branch 3 not taken.
5541 return freeposcache[zc_oldrand()%frees];
21919
21920 7 return -1;
21921 5548 }
21922
21923 33133 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
21924 {
21925 33133 bool placed=false;
21926 33133 int32_t t=-1;
21927
21928 // First: enemy combo flags
21929
2/2
✓ Branch 0 taken 355033 times.
✓ Branch 1 taken 31229 times.
386262 for(int32_t sy=0; sy<176; sy+=16)
21930 {
21931
2/2
✓ Branch 0 taken 5666694 times.
✓ Branch 1 taken 353129 times.
6019823 for(int32_t sx=0; sx<256; sx+=16)
21932 {
21933 5666694 int32_t cflag = MAPFLAG(sx, sy);
21934 5666694 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
21935
21936
2/4
✓ Branch 0 taken 5666694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5666694 times.
✗ Branch 3 not taken.
5666694 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
21937 {
21938 if(!ok2add(tmpscr->enemy[i]))
21939 {
21940 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21941 }
21942 else
21943 {
21944 addenemy(sx,
21945 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21946 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21947
21948 ++guycnt;
21949
21950 placed=true;
21951 goto placed_enemy;
21952 }
21953 }
21954
21955
4/4
✓ Branch 0 taken 5664790 times.
✓ Branch 1 taken 1904 times.
✓ Branch 2 taken 5664790 times.
✓ Branch 3 taken 1904 times.
5666694 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
21956 {
21957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1904 times.
1904 if(!ok2add(tmpscr->enemy[i]))
21958 {
21959 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21960 }
21961 else
21962 {
21963 3808 addenemy(sx,
21964
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1904 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1904 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21965
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1904 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1904 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21966
21967 1904 ++guycnt;
21968
21969 1904 placed=true;
21970 1904 goto placed_enemy;
21971 }
21972 }
21973 5664790 }
21974 353129 }
21975
21976 // Next: enemy pattern
21977
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 26337 times.
✓ Branch 2 taken 25744 times.
✓ Branch 3 taken 5485 times.
✓ Branch 4 taken 25744 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 25744 times.
31229 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
21978 {
21979 25744 do
21980 {
21981
21982 // NES positions
21983 40408 pos%=9;
21984 40408 x=stx[loadside][pos];
21985 40408 y=sty[loadside][pos];
21986 40408 ++pos;
21987 40408 ++t;
21988
2/2
✓ Branch 0 taken 14664 times.
✓ Branch 1 taken 25744 times.
66152 }
21989
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 40345 times.
40408 while((t< 20) && !is_starting_pos(i,x,y,t));
21990 25744 }
21991
21992
4/4
✓ Branch 0 taken 25744 times.
✓ Branch 1 taken 5485 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 25681 times.
31229 if(t<0 || t >= 20) // above enemy pattern failed
21993 {
21994 // Final chance: find a random position anywhere onscreen
21995 5548 int32_t randpos = placeenemy(i);
21996
21997
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 5541 times.
5548 if(randpos>-1)
21998 {
21999 5541 x=(randpos&15)<<4;
22000 5541 y= randpos&0xF0;
22001 5541 }
22002 else // All opportunities failed - abort
22003 {
22004 7 return;
22005 }
22006 5541 }
22007
22008 {
22009 31222 int32_t c=0;
22010 31222 c=clk;
22011
22012
2/2
✓ Branch 0 taken 4923 times.
✓ Branch 1 taken 26299 times.
31222 if(!slowguy(tmpscr->enemy[i]))
22013 26299 ++fastguys;
22014
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 4188 times.
4923 else if(fastguys>0)
22015 735 c=-15*(i-fastguys+2);
22016 else
22017 4188 c=-15*(i+1);
22018
22019
4/6
✓ Branch 0 taken 2085 times.
✓ Branch 1 taken 29137 times.
✓ Branch 2 taken 2085 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2085 times.
31222 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
22020 {
22021 // Special case for blue leevers
22022
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2083 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2085 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
22023 2 c=-15*(i+1);
22024 else
22025 2083 c=-15;
22026 2085 }
22027
22028
2/2
✓ Branch 0 taken 30928 times.
✓ Branch 1 taken 294 times.
31222 if(!ok2add(tmpscr->enemy[i]))
22029 {
22030
4/6
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 247 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
294 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
22031 294 }
22032 else
22033 {
22034
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30928 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
22035 {
22036
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 30845 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
61856 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
22037
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 30845 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
30928 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
22038
22039 30928 ++guycnt;
22040 30928 }
22041 }
22042
22043 31222 placed=true;
22044 31222 } // if(t < 20)
22045
22046 placed_enemy:
22047
22048 // I don't like this, but it seems to work...
22049 static bool foundCarrier;
22050
22051
2/2
✓ Branch 0 taken 25297 times.
✓ Branch 1 taken 7829 times.
33126 if(i==0)
22052 7829 foundCarrier=false;
22053
22054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33126 times.
33126 if(placed)
22055 {
22056
4/4
✓ Branch 0 taken 7829 times.
✓ Branch 1 taken 25297 times.
✓ Branch 2 taken 7690 times.
✓ Branch 3 taken 139 times.
33126 if(i==0 && tmpscr->enemyflags&efLEADER)
22057 {
22058 139 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22059
22060
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 7 times.
139 if(index!=-1)
22061 {
22062 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
22063
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_bit(quest_rules, qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
22064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(index!=-1)
22065 {
22066 132 ((enemy*)guys.spr(index))->leader = true;
22067 132 }
22068 132 }
22069 139 }
22070
22071
4/4
✓ Branch 0 taken 33026 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 32997 times.
✓ Branch 3 taken 29 times.
33126 if(!foundCarrier && hasitem&(4|2))
22072 {
22073 29 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22074
22075
2/4
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
22076 {
22077 29 ((enemy*)guys.spr(index))->itemguy = true;
22078 29 foundCarrier=true;
22079 29 }
22080 29 }
22081 33126 }
22082 33133 }
22083
22084 bool scriptloadenemies()
22085 {
22086 loaded_enemies = true;
22087 if(script_sle || sle_clk) return false;
22088 if(tmpscr->pattern==pNOSPAWN) return false;
22089
22090 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22091 {
22092 script_side_load_enemies();
22093 return true;
22094 }
22095
22096 int32_t pos=zc_oldrand()%9;
22097 int32_t clk=-15,x=0,y=0,fastguys=0;
22098 int32_t i=0,guycnt=0;
22099 int32_t loadcnt = 10;
22100
22101 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22102 {
22103 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22104
22105 --clk;
22106 }
22107 return true;
22108 }
22109
22110 6404523 void loadenemies()
22111 {
22112
3/4
✓ Branch 0 taken 6404523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 6362149 times.
6404523 if(script_sle || sle_clk)
22113 {
22114 42374 side_load_enemies();
22115 42374 return;
22116 }
22117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6362149 times.
6362149 if(tmpscr->pattern==pNOSPAWN) return;
22118
2/2
✓ Branch 0 taken 6348786 times.
✓ Branch 1 taken 13363 times.
6362149 if(loaded_enemies)
22119 6348786 return;
22120
22121 // check if it's the dungeon boss and it has been beaten before
22122
4/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 13231 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 34 times.
13363 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
22123 {
22124 34 loaded_enemies = true;
22125 34 return;
22126 }
22127
22128
4/4
✓ Branch 0 taken 12992 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 12751 times.
13329 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22129 {
22130 578 side_load_enemies();
22131 578 return;
22132 }
22133
22134 12751 loaded_enemies=true;
22135
22136 // do enemies that are always loaded
22137 12751 load_default_enemies();
22138
22139 // dungeon basements
22140
22141 static byte dngn_enemy_x[4] = {32,96,144,208};
22142
22143
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 12072 times.
12751 if(currscr>=128)
22144 {
22145
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
22146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
22147 {
22148 for(int32_t i=0; i<10; i++)
22149 {
22150 if ( tmpscr->enemy[i] )
22151 {
22152 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
22153 }
22154 }
22155 }
22156 else
22157 {
22158
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
22159
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
22160 }
22161 340 return;
22162 }
22163
22164 // check if it's been long enough to reload all enemies
22165
22166 12072 int32_t loadcnt = 10;
22167 12072 int16_t s = (currmap<<7)+currscr;
22168 12072 bool beenhere = false;
22169 12072 bool reload = true;
22170 12072 bool unbeatablereload = true;
22171
22172
2/2
✓ Branch 0 taken 72432 times.
✓ Branch 1 taken 12072 times.
84504 for(int32_t i=0; i<6; i++)
22173
2/2
✓ Branch 0 taken 68853 times.
✓ Branch 1 taken 3579 times.
76011 if(visited[i]==s)
22174 3579 beenhere = true;
22175
22176
2/2
✓ Branch 0 taken 3579 times.
✓ Branch 1 taken 8493 times.
12072 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
22177 {
22178 8493 visited[vhead]=s; //If not, it adds it to the array,
22179 8493 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
22180 8493 }
22181
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 1967 times.
3579 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
22182 {
22183 1967 loadcnt = 0; //It will tell it not to load any enemies,
22184 1967 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
22185 1967 }
22186
22187
2/2
✓ Branch 0 taken 1967 times.
✓ Branch 1 taken 10105 times.
12072 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
22188 {
22189 10105 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
22190
22191
2/4
✓ Branch 0 taken 3443 times.
✓ Branch 1 taken 6662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10105 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
22192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3443 times.
3443 (get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
22193 6662 loadcnt = 10; //That means all enemies need to be respawned.
22194
3/4
✓ Branch 0 taken 8493 times.
✓ Branch 1 taken 1612 times.
✓ Branch 2 taken 8493 times.
✗ Branch 3 not taken.
10105 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
22195 {
22196 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
22197 {
22198 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
22199 {
22200 unbeatablereload = false;
22201 }
22202 }
22203 if (unbeatablereload)
22204 {
22205 loadcnt = 10;
22206 }
22207 }
22208 10105 }
22209
22210
4/4
✓ Branch 0 taken 11953 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 11903 times.
12072 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
22211 169 loadcnt = 10; //All enemies also need to be respawned.
22212
22213 12072 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
22214 12072 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
22215 12072 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
22216
22217
4/4
✓ Branch 0 taken 5560 times.
✓ Branch 1 taken 39645 times.
✓ Branch 2 taken 33133 times.
✓ Branch 3 taken 12072 times.
45205 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22218 {
22219 33133 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22220
22221 33133 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
22222 33133 }
22223
22224 12072 game->guys[s] = guycnt;
22225 //} //if(true)
22226 6404523 }
22227 121 void moneysign()
22228 {
22229 121 additem(48,108,iRupy,ipDUMMY);
22230 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
22231 121 set_clip_state(pricesdisplaybuf, 0);
22232 121 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
22233 121 }
22234
22235 927 void putprices(bool sign)
22236 {
22237
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 921 times.
927 if(fadeclk > 0) return;
22238 // refresh what's under the prices
22239 // for(int32_t i=5; i<12; i++)
22240 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
22241
22242 921 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
22243 921 int32_t step=32;
22244 921 int32_t x=80;
22245
22246
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 774 times.
921 if(prices[2]==0)
22247 {
22248 774 step<<=1;
22249
22250
2/2
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 20 times.
774 if(prices[1]==0)
22251 {
22252 754 x=112;
22253 754 }
22254 774 }
22255
22256
2/2
✓ Branch 0 taken 921 times.
✓ Branch 1 taken 2763 times.
3684 for(int32_t i=0; i<3; i++)
22257 {
22258 // Kind of stupid, but it works: 100000 is used to indicate that an item
22259 // has a price of zero rather than there being no item.
22260 // 100000 isn't a valid price, so this doesn't cause problems.
22261
3/4
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 2256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 507 times.
2763 if(prices[i]!=0 && prices[i]<100000)
22262 {
22263 char buf[8];
22264 507 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
22265
22266 507 int32_t l=(int32_t)strlen(buf);
22267 507 set_clip_state(pricesdisplaybuf, 0);
22268
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 486 times.
507 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
22269 507 }
22270
22271 2763 x+=step;
22272 2763 }
22273 927 }
22274
22275 // Setting up special rooms
22276 // Also called when the Letter is used successfully.
22277 572 void setupscreen()
22278 {
22279 572 boughtsomething=false;
22280 572 int32_t t=currscr<128?0:1;
22281 572 word str=tmpscr[t].str;
22282
22283 // Prices are already set to 0 in dowarp()
22284
13/15
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 28 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
572 switch(tmpscr[t].room)
22285 {
22286 case rSP_ITEM: // special item
22287 101 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22288 101 break;
22289
22290 case rINFO: // pay for info
22291 {
22292 10 int32_t count = 0;
22293 10 int32_t base = 88;
22294 10 int32_t step = 5;
22295
22296 10 moneysign();
22297
22298
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 30 times.
40 for(int32_t i=0; i<3; i++)
22299 {
22300
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(QMisc.info[tmpscr[t].catchall].str[i])
22301 {
22302 30 ++count;
22303 30 }
22304 else
22305 break;
22306 30 }
22307
22308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(count)
22309 {
22310
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(count==1)
22311 {
22312 base = 88+32;
22313 }
22314
22315
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(count==2)
22316 {
22317 step = 6;
22318 }
22319
22320
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 10 times.
40 for(int32_t i=0; i < count; i++)
22321 {
22322 30 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
22323 30 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22324 30 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
22325
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(prices[i]==0)
22326 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22327 30 int32_t itemid = current_item_id(itype_wealthmedal);
22328
22329
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if(itemid>=0 && prices[i]!=100000)
22330 {
22331 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22332 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22333 else
22334 prices[i]-=itemsbuf[itemid].misc1;
22335 prices[i]=vbound(prices[i], -99999, 0);
22336 if(prices[i]==0)
22337 prices[i]=100000;
22338 }
22339
22340
2/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
22341 prices[i]=-1;
22342 30 }
22343 10 }
22344
22345 10 break;
22346 }
22347
22348 case rMONEY: // secret money
22349 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
22350 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22351 38 break;
22352
22353 case rGAMBLE: // gambling
22354 6 prices[0]=prices[1]=prices[2]=-10;
22355 6 moneysign();
22356 6 additem(88,89,iRupy,ipMONEY+ipDUMMY);
22357 6 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22358 6 additem(120,89,iRupy,ipMONEY+ipDUMMY);
22359 6 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22360 6 additem(152,89,iRupy,ipMONEY+ipDUMMY);
22361 6 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
22362 6 break;
22363
22364 case rREPAIR: // door repair
22365
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
22366 // }
22367 12 repaircharge=tmpscr[t].catchall;
22368 12 break;
22369
22370 case rMUPGRADE: // upgrade magic
22371 1 adjustmagic=true;
22372 1 break;
22373
22374 case rLEARNSLASH: // learn slash attack
22375 1 learnslash=true;
22376 1 break;
22377
22378 case rRP_HC: // heart container or red potion
22379 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
22380 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22381 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
22382 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22383 12 break;
22384
22385 case rP_SHOP: // potion shop
22386
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 20 times.
28 if(current_item(itype_letter)<i_letter_used)
22387 {
22388 8 str=0;
22389 8 break;
22390 }
22391
22392 [[fallthrough]];
22393 case rTAKEONE: // take one
22394 case rSHOP: // shop
22395 {
22396 106 int32_t count = 0;
22397 106 int32_t base = 88;
22398 106 int32_t step = 5;
22399
22400
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 105 times.
106 if(tmpscr[t].room != rTAKEONE)
22401 105 moneysign();
22402
22403 //count and align the stuff
22404
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 314 times.
409 for(int32_t i=0; i<3; ++i)
22405 {
22406
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 11 times.
314 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
22407 {
22408 303 ++count;
22409 303 }
22410 else
22411 {
22412 11 break;
22413 }
22414 303 }
22415
22416
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 4 times.
106 if(count==1)
22417 {
22418 4 base = 88+32;
22419 4 }
22420
22421
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 7 times.
106 if(count==2)
22422 {
22423 7 step = 6;
22424 7 }
22425
22426
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 106 times.
409 for(int32_t i=0; i<count; i++)
22427 {
22428 303 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
22429 303 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22430
22431
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 301 times.
303 if(tmpscr[t].room != rTAKEONE)
22432 {
22433 301 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
22434
1/2
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
301 if(prices[i]==0)
22435 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22436 301 int32_t itemid = current_item_id(itype_wealthmedal);
22437
22438
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 301 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
301 if(itemid>=0 && prices[i]!=100000)
22439 {
22440 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22441 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22442 else
22443 prices[i]+=itemsbuf[itemid].misc1;
22444 prices[i]=vbound(prices[i], 0, 99999);
22445 if(prices[i]==0)
22446 prices[i]=100000;
22447 }
22448
22449
2/4
✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 301 times.
✗ Branch 3 not taken.
301 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
22450 prices[i]=1;
22451 301 }
22452 303 }
22453
22454 106 break;
22455 }
22456 case rBOTTLESHOP: // bottle shop
22457 {
22458 int32_t count = 0;
22459 int32_t base = 88;
22460 int32_t step = 5;
22461
22462 moneysign();
22463 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
22464 //count and align the stuff
22465 for(int32_t i=0; i<3; ++i)
22466 {
22467 if(bst.fill[count] != 0)
22468 {
22469 ++count;
22470 }
22471 else
22472 {
22473 break;
22474 }
22475 }
22476
22477 if(count==1)
22478 {
22479 base = 88+32;
22480 }
22481
22482 if(count==2)
22483 {
22484 step = 6;
22485 }
22486
22487 for(int32_t i=0; i<count; i++)
22488 {
22489 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
22490 //{ Setup dummy item
22491 item* curItem = ((item*)items.spr(items.Count()-1));
22492 curItem->PriceIndex = i;
22493 newcombo const& cmb = combobuf[bst.comb[i]];
22494 curItem->o_tile = cmb.o_tile;
22495 curItem->o_cset = bst.cset[i];
22496 curItem->cs = curItem->o_cset;
22497 curItem->tile = cmb.o_tile;
22498 curItem->o_speed = cmb.speed;
22499 curItem->o_delay = 0;
22500 curItem->frames = cmb.frames;
22501 curItem->flip = cmb.flip;
22502 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
22503 curItem->pstring = 0;
22504 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
22505 curItem->flash = false;
22506 curItem->twohand = false;
22507 curItem->anim = true;
22508 curItem->hxsz=1;
22509 curItem->hyofs=4;
22510 curItem->hysz=12;
22511 curItem->script=0;
22512 curItem->txsz=1;
22513 curItem->tysz=1;
22514 //}
22515
22516 prices[i] = bst.price[i];
22517 if(prices[i]==0)
22518 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22519 int32_t itemid = current_item_id(itype_wealthmedal);
22520
22521 if(itemid>=0 && prices[i]!=100000)
22522 {
22523 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22524 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22525 else
22526 prices[i]+=itemsbuf[itemid].misc1;
22527 prices[i]=vbound(prices[i], 0, 99999);
22528 if(prices[i]==0)
22529 prices[i]=100000;
22530 }
22531
22532 if((bst.price[i])>1 && prices[i]<1)
22533 prices[i]=1;
22534 }
22535
22536 break;
22537 }
22538
22539 case rBOMBS: // more bombs
22540 8 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22541 8 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22542 8 prices[0]=-tmpscr[t].catchall;
22543 8 break;
22544
22545 case rARROWS: // more arrows
22546 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22547 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22548 prices[0]=-tmpscr[t].catchall;
22549 break;
22550
22551 case rSWINDLE: // leave heart container or money
22552 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
22553 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22554 13 prices[0]=-1;
22555 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
22556 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22557 13 prices[1]=-tmpscr[t].catchall;
22558 13 break;
22559
22560 }
22561
22562
3/4
✓ Branch 0 taken 564 times.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 564 times.
572 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
22563 {
22564 8 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
22565 8 int32_t itemid = current_item_id(itype_wealthmedal);
22566
22567
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemid >= 0)
22568 {
22569 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22570 prices[i]*=(itemsbuf[itemid].misc1/100.0);
22571 else
22572 prices[i]+=itemsbuf[itemid].misc1;
22573 }
22574
22575
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 if(tmpscr[t].catchall>1 && prices[i]>-1)
22576 prices[i]=-1;
22577 8 }
22578
22579 572 putprices(false);
22580
22581
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 31 times.
572 if(str)
22582 {
22583 541 donewmsg(str);
22584 541 }
22585 else
22586 {
22587 31 Hero.unfreeze();
22588 }
22589 572 }
22590
22591 // Increments msgptr and returns the control code argument pointed at.
22592 630 word grab_next_argument()
22593 {
22594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
22595 630 byte val=MsgStrings[msgstr].s[++msgptr]-1;
22596 630 word ret=val;
22597
22598 // If an argument is succeeded by 255, then it's a three-byte argument -
22599 // between 254 and 65535 (or whatever the maximum actually is)
22600
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
22601
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
22602 {
22603 val=MsgStrings[msgstr].s[msgptr+2];
22604 word next=val;
22605 ret += 254*next;
22606 msgptr+=2;
22607 }
22608
22609 630 return ret;
22610 630 }
22611
22612 enum
22613 {
22614 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
22615 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
22616
22617 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
22618
22619 MNU_DATA_MAX
22620 };
22621 struct menu_choice
22622 {
22623 int32_t x, y;
22624 int32_t pos;
22625 int32_t upos, dpos, lpos, rpos;
22626 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
22627 {}
22628 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
22629 int32_t dpos, int32_t lpos, int32_t rpos)
22630 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
22631 {}
22632 };
22633 static int32_t msg_menu_data[MNU_DATA_MAX];
22634 static bool do_run_menu = false;
22635 bool do_end_str = false;
22636 static bool wait_advance = false;
22637 34 static std::map<int32_t, menu_choice> menu_options;
22638 15248 void clr_msg_data()
22639 {
22640 15248 do_end_str = false;
22641 15248 wait_advance = false;
22642 15248 do_run_menu = false;
22643 15248 menu_options.clear();
22644 15248 memset(msg_menu_data, 0, sizeof(msg_menu_data));
22645 15248 }
22646
22647 static bool doing_name_insert = false;
22648 static char namebuf[9] = {0};
22649 static char* nameptr = NULL;
22650 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
22651 bool runMenuCursor()
22652 {
22653 clear_bitmap(msg_menu_bmp_buf);
22654 if(!menu_options.size())
22655 {
22656 msg_menu_data[MNU_CHOSEN] = 0;
22657 return true; //end menu
22658 }
22659 int32_t pos = msg_menu_data[MNU_CHOSEN];
22660 //If the cursor is at an invalid pos, find the first pos >= 0...
22661 if(menu_options.find(pos) == menu_options.end())
22662 {
22663 pos = 0;
22664 while(menu_options.find(pos) == menu_options.end())
22665 ++pos;
22666 }
22667 menu_choice* ch = &menu_options[pos];
22668
22669 bool pressed = true;
22670 if(rUp()) pos = ch->upos;
22671 else if(rDown()) pos = ch->dpos;
22672 else if(rLeft()) pos = ch->lpos;
22673 else if(rRight()) pos = ch->rpos;
22674 else pressed = false;
22675
22676 if(pressed)
22677 msg_menu_data[MNU_TIMER] = 1;
22678
22679 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
22680 bool held = false;
22681 if(hold_input)
22682 {
22683 held = true;
22684 if(Up()) pos = ch->upos;
22685 else if(Down()) pos = ch->dpos;
22686 else if(Left()) pos = ch->lpos;
22687 else if(Right()) pos = ch->rpos;
22688 else held = false;
22689 }
22690 //If the cursor is at an invalid pos, find the first pos >= 0...
22691 if(menu_options.find(pos) == menu_options.end())
22692 {
22693 pos = 0;
22694 while(menu_options.find(pos) == menu_options.end())
22695 ++pos;
22696 }
22697 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
22698 sfx(MsgStrings[msgstr].sfx);
22699
22700 ch = &menu_options[pos];
22701 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
22702 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
22703 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
22704 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
22705
22706 msg_menu_data[MNU_CHOSEN] = pos;
22707
22708 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
22709 {
22710 rAbtn(); //Eat
22711 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
22712 }
22713
22714 bool ret = (pressed || held) ? false : rAbtn();
22715 //Eat inputs
22716 rUp(); rDown(); rLeft(); rRight(); rAbtn();
22717
22718 if(ret)
22719 menu_options.clear();
22720
22721 return ret;
22722 //false if pos changed this frame; no confirming while moving the cursor!
22723 }
22724
22725 140856 bool bottom_margin_clip()
22726 {
22727 141156 return !get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)
22728
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 140556 times.
140856 && cursor_y >= (msg_h + (get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
22729 }
22730
22731 void update_msgstr();
22732 56753 bool parsemsgcode()
22733 {
22734
2/2
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 56244 times.
56753 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
22735 56244 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
22736
4/38
✗ Branch 0 not taken.
✓ Branch 1 taken 55914 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 301 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
56244 switch(c)
22737 {
22738 case MSGC_NEWLINE:
22739 {
22740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22741 1 ssc_tile_hei = ssc_tile_hei_buf;
22742 1 ssc_tile_hei_buf = -1;
22743 1 cursor_y += thei + MsgStrings[msgstr].vspace;
22744 1 cursor_x=msg_margins[left];
22745 1 return true;
22746 }
22747
22748 case MSGC_COLOUR:
22749 {
22750 301 int32_t cset = (grab_next_argument());
22751 301 msgcolour = CSET(cset)+(grab_next_argument());
22752 301 return true;
22753 }
22754
22755 case MSGC_SHDCOLOR:
22756 {
22757 int32_t cset = (grab_next_argument());
22758 msg_shdcol = CSET(cset)+(grab_next_argument());
22759 return true;
22760 }
22761 case MSGC_SHDTYPE:
22762 {
22763 msg_shdtype = grab_next_argument();
22764 return true;
22765 }
22766
22767 case MSGC_SPEED:
22768 {
22769 28 msgspeed=grab_next_argument();
22770 28 return true;
22771 }
22772
22773 case MSGC_CTRUP:
22774 {
22775 int32_t a1 = grab_next_argument();
22776 int32_t a2 = grab_next_argument();
22777 game->change_counter(a2, a1);
22778 return true;
22779 }
22780
22781 case MSGC_CTRDN:
22782 {
22783 int32_t a1 = grab_next_argument();
22784 int32_t a2 = grab_next_argument();
22785 game->change_counter(-a2, a1);
22786 return true;
22787 }
22788
22789 case MSGC_CTRSET:
22790 {
22791 int32_t a1 = grab_next_argument();
22792 int32_t a2 = grab_next_argument();
22793 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
22794 return true;
22795 }
22796
22797 case MSGC_CTRUPPC:
22798 case MSGC_CTRDNPC:
22799 case MSGC_CTRSETPC:
22800 {
22801 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
22802 int32_t counter = grab_next_argument();
22803 int32_t amount = grab_next_argument();
22804 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
22805
22806 if(code==MSGC_CTRDNPC)
22807 amount*=-1;
22808
22809 if(code==MSGC_CTRSETPC)
22810 game->set_counter(amount, counter);
22811 else
22812 game->change_counter(amount, counter);
22813
22814 return true;
22815 }
22816
22817 case MSGC_GIVEITEM:
22818 {
22819 int32_t itemID = grab_next_argument();
22820
22821 getitem(itemID, true);
22822 if ( !item_doscript[itemID] && (((unsigned)itemID) < 256) )
22823 {
22824 itemScriptData[itemID].Clear();
22825 memset(item_stack[itemID], 0xFFFF, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
22826 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) item_doscript[itemID] = 1;
22827 }
22828 return true;
22829 }
22830
22831
22832 case MSGC_WARP:
22833 {
22834 int32_t dmap = grab_next_argument();
22835 int32_t scrn = grab_next_argument();
22836 int32_t dx = grab_next_argument();
22837 int32_t dy = grab_next_argument();
22838 int32_t wfx = grab_next_argument();
22839 int32_t sfx = grab_next_argument();
22840 if(dx >= MAX_SCC_ARG) dx = -1;
22841 if(dy >= MAX_SCC_ARG) dy = -1;
22842 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
22843 return true;
22844 }
22845
22846 case MSGC_SETSCREEND:
22847 {
22848 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22849 int32_t screen = grab_next_argument();
22850 int32_t reg = grab_next_argument();
22851 int32_t val = grab_next_argument();
22852 FFCore.set_screen_d(screen + dmap, reg, val);
22853 return true;
22854 }
22855 case MSGC_TAKEITEM:
22856 {
22857 int32_t itemID = grab_next_argument();
22858 if ( item_doscript[itemID] )
22859 {
22860 item_doscript[itemID] = 4; //Val of 4 means 'clear stack and quit'
22861 }
22862 takeitem(itemID);
22863 if ( game->forced_bwpn == itemID )
22864 {
22865 game->forced_bwpn = -1;
22866 } //not else if! -Z
22867 if ( game->forced_awpn == itemID )
22868 {
22869 game->forced_awpn = -1;
22870 }
22871 if ( game->forced_xwpn == itemID )
22872 {
22873 game->forced_xwpn = -1;
22874 } //not else if! -Z
22875 if ( game->forced_ywpn == itemID )
22876 {
22877 game->forced_ywpn = -1;
22878 }
22879 verifyBothWeapons();
22880 return true;
22881 }
22882
22883 case MSGC_SFX:
22884 {
22885 sfx((int32_t)grab_next_argument(),128);
22886 return true;
22887 }
22888
22889 case MSGC_MIDI:
22890 {
22891 int32_t music = (int32_t)(grab_next_argument());
22892
22893 if(music==0)
22894 music_stop();
22895 else
22896 jukebox(music+(ZC_MIDI_COUNT-1));
22897
22898 return true;
22899 }
22900
22901 case MSGC_NAME:
22902 {
22903 doing_name_insert = true;
22904 sprintf(namebuf, "%s", game->get_name());
22905 nameptr = namebuf;
22906 return true;
22907 }
22908
22909 case MSGC_FONT:
22910 {
22911 int fontid = grab_next_argument();
22912 int oh = text_height(msgfont);
22913 msgfont = get_zc_font(fontid);
22914 int nh = text_height(msgfont);
22915 int mh = std::max(oh,nh);
22916 if(mh > ssc_tile_hei_buf)
22917 ssc_tile_hei_buf = mh;
22918 return true;
22919 }
22920 case MSGC_RUN_FRZ_GENSCR:
22921 {
22922 word scr_id = grab_next_argument();
22923 bool force_redraw = grab_next_argument()!=0;
22924 if(force_redraw)
22925 {
22926 update_msgstr();
22927 draw_screen(tmpscr);
22928 }
22929 FFCore.runGenericFrozenEngine(scr_id);
22930 return true;
22931 }
22932 case MSGC_DRAWTILE:
22933 {
22934 int32_t tl = grab_next_argument();
22935 int32_t cs = grab_next_argument();
22936 int32_t t_wid = grab_next_argument();
22937 int32_t t_hei = grab_next_argument();
22938 int32_t fl = grab_next_argument();
22939
22940 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
22941 {
22942 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22943 ssc_tile_hei = ssc_tile_hei_buf;
22944 ssc_tile_hei_buf = -1;
22945 cursor_y += thei + MsgStrings[msgstr].vspace;
22946 if(bottom_margin_clip()) return true;
22947 cursor_x=msg_margins[left];
22948 }
22949
22950 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
22951 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
22952 cursor_x += MsgStrings[msgstr].hspace + t_wid;
22953 return true;
22954 }
22955
22956 case MSGC_GOTOIFRAND:
22957 {
22958 int32_t odds = (int32_t)(grab_next_argument());
22959
22960 if(!odds || !(zc_oldrand()%odds))
22961 goto switched;
22962
22963 (void)grab_next_argument();
22964 return true;
22965 }
22966
22967 case MSGC_GOTOIFGLOBAL:
22968 {
22969 int32_t arg = (int32_t)grab_next_argument();
22970 int32_t d = zc_min(7,arg);
22971 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22972 arg = (int32_t)grab_next_argument();
22973
22974 if(game->screen_d[s][d] >= arg)
22975 goto switched;
22976
22977 (void)grab_next_argument();
22978 return true;
22979 }
22980
22981 case MSGC_CHANGEPORTRAIT:
22982 {
22983 return true; //not implemented
22984 }
22985
22986 case MSGC_GOTOIFCREEND:
22987 {
22988 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22989 int32_t screen = grab_next_argument();
22990 int32_t reg = grab_next_argument();
22991 int32_t val = grab_next_argument();
22992 //int32_t nxtstr = grab_next_argument();
22993 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
22994 {
22995 goto switched;
22996 }
22997 (void)grab_next_argument();
22998 return true;
22999 }
23000
23001 case MSGC_GOTOIF:
23002 {
23003 int32_t it = (int32_t)grab_next_argument();
23004
23005 if(unsigned(it)<MAXITEMS && game->item[it])
23006 goto switched;
23007
23008 (void)grab_next_argument();
23009 return true;
23010 }
23011
23012 case MSGC_GOTOIFCTR:
23013 {
23014 if(game->get_counter(grab_next_argument())>=grab_next_argument())
23015 goto switched;
23016
23017 (void)grab_next_argument();
23018 return true;
23019 }
23020
23021 case MSGC_GOTOIFCTRPC:
23022 {
23023 int32_t counter = grab_next_argument();
23024 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
23025
23026 if(game->get_counter(counter)>=amount)
23027 goto switched;
23028
23029 (void)grab_next_argument();
23030 return true;
23031 }
23032
23033 case MSGC_GOTOIFTRICOUNT:
23034 {
23035 if(TriforceCount() >= (int32_t)(grab_next_argument()))
23036 goto switched;
23037
23038 (void)grab_next_argument();
23039 return true;
23040 }
23041
23042 case MSGC_GOTOIFTRI:
23043 {
23044 int32_t lev = (int32_t)(grab_next_argument());
23045
23046 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
23047 goto switched;
23048
23049 (void)grab_next_argument();
23050 return true;
23051 }
23052
23053 case MSGC_SETUPMENU:
23054 {
23055 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
23056 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
23057 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
23058 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
23059 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
23060 return true;
23061 }
23062
23063 case MSGC_MENUCHOICE:
23064 {
23065 int32_t pos = grab_next_argument();
23066 int32_t upos = grab_next_argument();
23067 int32_t dpos = grab_next_argument();
23068 int32_t lpos = grab_next_argument();
23069 int32_t rpos = grab_next_argument();
23070 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
23071 {
23072 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23073 ssc_tile_hei = ssc_tile_hei_buf;
23074 ssc_tile_hei_buf = -1;
23075 cursor_y += thei + MsgStrings[msgstr].vspace;
23076 if(bottom_margin_clip()) break;
23077 cursor_x=msg_margins[left];
23078 }
23079
23080 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
23081 upos, dpos, lpos, rpos);
23082
23083 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
23084 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
23085 return true;
23086 }
23087
23088 case MSGC_RUNMENU:
23089 {
23090 msg_menu_data[MNU_CHOSEN] = 0;
23091 msg_menu_data[MNU_CAN_CONFIRM] = 0;
23092 if(menu_options.size() < 1)
23093 return true;
23094 do_run_menu = true;
23095 return true;
23096 }
23097
23098 case MSGC_GOTOMENUCHOICE:
23099 {
23100 int32_t choice = grab_next_argument();
23101 if(msg_menu_data[MNU_CHOSEN] == choice)
23102 goto switched;
23103 (void)grab_next_argument();
23104 return true;
23105 }
23106
23107 case MSGC_ENDSTRING:
23108 {
23109 do_end_str = true;
23110 return true;
23111 }
23112 case MSGC_WAIT_ADVANCE:
23113 {
23114 wait_advance = true;
23115 linkedmsgclk = 51;
23116 return true;
23117 }
23118 case MSGC_TRIGSECRETS:
23119 {
23120 bool perm = (bool)grab_next_argument();
23121 hidden_entrance(0, true, false, -8);
23122 if(perm)
23123 setmapflag(mSECRET);
23124 return true;
23125 }
23126 case MSGC_SETSCREENSTATE:
23127 {
23128 int32_t flag = int32_t(grab_next_argument());
23129 if(unsigned(flag)>=mMAXIND)
23130 {
23131 Z_error("SCC 133: Flag %d is invalid\n", flag);
23132 return true;
23133 }
23134 bool state = bool(grab_next_argument());
23135 if(state)
23136 setmapflag(1<<flag);
23137 else
23138 unsetmapflag(1<<flag,true);
23139 return true;
23140 }
23141 case MSGC_SETSCREENSTATER:
23142 {
23143 int32_t map = (int32_t)grab_next_argument();
23144 int32_t scrid = (int32_t)grab_next_argument();
23145 if(map < 1 || map > map_count)
23146 {
23147 Z_error("SCC 134: Map %d is invalid\n", map);
23148 return true;
23149 }
23150 if(unsigned(scrid)>=0x80)
23151 {
23152 Z_error("SCC 134: Screen %d is invalid\n", scrid);
23153 return true;
23154 }
23155
23156 int32_t flag = int32_t(grab_next_argument());
23157 if(unsigned(flag)>=mMAXIND)
23158 {
23159 Z_error("SCC 134: Flag %d is invalid\n", flag);
23160 return true;
23161 }
23162 bool state = bool(grab_next_argument());
23163 if(state)
23164 setmapflag(mapind(map,scrid),1<<flag);
23165 else
23166 unsetmapflag(mapind(map,scrid),1<<flag,true);
23167 return true;
23168 }
23169 switched:
23170 int32_t lev = (int32_t)(grab_next_argument());
23171 if(lev && get_bit(quest_rules, qr_SCC_GOTO_RESPECTS_CONTFLAG)
23172 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
23173 {
23174 msgstr=lev;
23175 msgpos=msgptr=0;
23176 msgfont=setmsgfont();
23177 }
23178 else donewmsg(lev);
23179 msgptr--; // To counteract it being incremented after this routine is called.
23180 putprices(false);
23181 return true;
23182 }
23183
23184 55914 return false;
23185 56753 }
23186
23187 // Wraps the message string... probably.
23188 54992 void wrapmsgstr(char *s3)
23189 {
23190 54992 int32_t j=0;
23191
23192
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 45313 times.
54992 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23193 {
23194
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
23195 {
23196 2081 char c = MsgStrings[msgstr].s[msgptr];
23197
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
23198 {
23199
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
23200 {
23201
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
23202 8026 }
23203
23204 1786 s3[j] = 0;
23205 1786 msgspace = false;
23206 1786 }
23207 else
23208 {
23209 295 s3[0] = c;
23210 295 s3[1] = 0;
23211 }
23212 2081 }
23213 else
23214 {
23215 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
23216 7598 s3[1] = 0;
23217
23218
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
23219 }
23220 9679 }
23221 else
23222 {
23223 45313 s3[0] = MsgStrings[msgstr].s[msgptr];
23224 45313 s3[1] = 0;
23225 }
23226 54992 }
23227
23228 // Returns true if the pointer is at a string's
23229 // null terminator or a trailing space
23230 165680 bool atend(char const* str)
23231 {
23232 165680 int32_t i=0;
23233
23234
2/2
✓ Branch 0 taken 1408350 times.
✓ Branch 1 taken 165680 times.
1574030 while(str[i]==' ')
23235 1408350 i++;
23236
23237 165680 return str[i]=='\0';
23238 }
23239
23240 6439294 void putmsg()
23241 {
23242 6439294 bool oldmargin = get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)!=0;
23243
2/2
✓ Branch 0 taken 6254603 times.
✓ Branch 1 taken 184691 times.
6439294 if(!msgorig) msgorig=msgstr;
23244
23245
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6439294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6439294 if(wait_advance && linkedmsgclk < 1)
23246 linkedmsgclk = 1;
23247
2/2
✓ Branch 0 taken 6399569 times.
✓ Branch 1 taken 39725 times.
6439294 if(linkedmsgclk>0)
23248 {
23249
2/2
✓ Branch 0 taken 14274 times.
✓ Branch 1 taken 25451 times.
39725 if(linkedmsgclk==1)
23250 {
23251
5/6
✓ Branch 0 taken 14274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13849 times.
✓ Branch 3 taken 425 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 13765 times.
14274 if(do_end_str||cAbtn()||cBbtn())
23252 {
23253 509 do_end_str = false;
23254 509 linkedmsgclk = 0;
23255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 509 times.
509 if(wait_advance)
23256 {
23257 wait_advance = false;
23258 }
23259 else
23260 {
23261 509 msgstr=MsgStrings[msgstr].nextstring;
23262
3/4
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 168 times.
✗ Branch 3 not taken.
509 if(!msgstr && enqueued_str)
23263 {
23264 msgstr = enqueued_str;
23265 enqueued_str = 0;
23266 }
23267
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 168 times.
509 if(!msgstr)
23268 {
23269 168 msgfont=get_zc_font(font_zfont);
23270
23271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 168 times.
168 if(tmpscr->room!=rGRUMBLE)
23272 168 blockpath=false;
23273
23274 168 dismissmsg();
23275 168 goto disappear;
23276 }
23277
23278 341 donewmsg(msgstr);
23279 341 putprices(false);
23280 }
23281 341 }
23282 14106 }
23283 else
23284 {
23285 25451 --linkedmsgclk;
23286 }
23287 39557 }
23288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6439126 times.
6439126 if(wait_advance) return; //Waiting for buttonpress
23289
23290
9/10
✓ Branch 0 taken 6439014 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 183725 times.
✓ Branch 3 taken 6255289 times.
✓ Branch 4 taken 123316 times.
✓ Branch 5 taken 60409 times.
✓ Branch 6 taken 63175 times.
✓ Branch 7 taken 60141 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 63175 times.
6439126 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
23291 {
23292
2/2
✓ Branch 0 taken 120550 times.
✓ Branch 1 taken 6255289 times.
6375839 if(!msgstr)
23293 6255289 msgorig=0;
23294
23295 6375839 msg_active = false;
23296 6375839 return;
23297 }
23298
23299 63287 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
23300
23301 char s3[145];
23302 int32_t tlength;
23303
23304 // Bypass the string with the B button!
23305
4/4
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 62966 times.
✓ Branch 2 taken 348 times.
✓ Branch 3 taken 62618 times.
63287 if(((cBbtn())&&(get_bit(quest_rules,qr_ALLOWMSGBYPASS))) || msgspeed==0)
23306 {
23307 //finish writing out the string
23308
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 36028 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 35502 times.
36169 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
23309 {
23310
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 18500 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
35502 if(msgspeed && !(cBbtn() && get_bit(quest_rules,qr_ALLOWMSGBYPASS)))
23311 goto breakout; // break out if message speed was changed to non-zero
23312
5/6
✓ Branch 0 taken 35500 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 35500 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 234 times.
✓ Branch 5 taken 35266 times.
35502 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23313 {
23314
1/2
✓ Branch 0 taken 35266 times.
✗ Branch 1 not taken.
35266 if(bottom_margin_clip())
23315 break;
23316
23317 35266 wrapmsgstr(s3);
23318
23319
2/2
✓ Branch 0 taken 8524 times.
✓ Branch 1 taken 26742 times.
35266 if(MsgStrings[msgstr].s[msgptr]==' ')
23320 {
23321 8524 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23322
23323
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 388 times.
8955 if(cursor_x+tlength > (msg_w-msg_margins[right])
23324
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 8093 times.
✓ Branch 2 taken 431 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 429 times.
✓ Branch 5 taken 41 times.
8524 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23325 43 ? true : strcmp(s3," ")!=0))
23326 {
23327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 388 times.
472 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23328 388 ssc_tile_hei = ssc_tile_hei_buf;
23329 388 ssc_tile_hei_buf = -1;
23330 388 cursor_y += thei + MsgStrings[msgstr].vspace;
23331
1/2
✓ Branch 0 taken 388 times.
✗ Branch 1 not taken.
388 if(bottom_margin_clip()) break;
23332 388 cursor_x=msg_margins[left];
23333 388 }
23334
23335 8522 char buf[2] = {0};
23336 8522 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23337
23338 8522 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23339
23340 8522 cursor_x+=tlength;
23341 8522 }
23342 else
23343 {
23344 26742 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23345
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 356 times.
27266 if(cursor_x+tlength > (msg_w-msg_margins[right])
23346
5/6
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 26175 times.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 399 times.
✗ Branch 5 not taken.
26742 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23347 168 ? true : strcmp(s3," ")!=0))
23348 {
23349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 567 times.
567 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23350 567 ssc_tile_hei = ssc_tile_hei_buf;
23351 567 ssc_tile_hei_buf = -1;
23352 567 cursor_y += thei + MsgStrings[msgstr].vspace;
23353
1/2
✓ Branch 0 taken 567 times.
✗ Branch 1 not taken.
567 if(bottom_margin_clip()) break;
23354 567 cursor_x=msg_margins[left];
23355 567 }
23356
23357 26742 sfx(MsgStrings[msgstr].sfx);
23358
23359 26742 char buf[2] = {0};
23360 26742 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23361
23362 26742 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23363
23364 26742 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23365 26742 cursor_x += MsgStrings[msgstr].hspace;
23366 }
23367
23368 35264 msgpos++;
23369 35264 }
23370
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(do_run_menu)
23371 {
23372 if(runMenuCursor())
23373 {
23374 do_run_menu = false;
23375 }
23376 else break;
23377 }
23378
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(doing_name_insert)
23379 {
23380 if(*nameptr)
23381 {
23382 if(bottom_margin_clip())
23383 break;
23384
23385 char s3[9] = {0};
23386
23387 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23388 {
23389 strcpy(s3, nameptr);
23390 }
23391 else
23392 {
23393 s3[0] = *nameptr;
23394 s3[1] = 0;
23395 }
23396
23397 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23398
23399 if(cursor_x+tlength > (msg_w-msg_margins[right])
23400 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23401 ? true : strcmp(s3," ")!=0))
23402 {
23403 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23404 ssc_tile_hei = ssc_tile_hei_buf;
23405 ssc_tile_hei_buf = -1;
23406 cursor_y += thei + MsgStrings[msgstr].vspace;
23407 if(bottom_margin_clip()) break;
23408 cursor_x=msg_margins[left];
23409 }
23410
23411 sfx(MsgStrings[msgstr].sfx);
23412
23413 char buf[2] = {0};
23414 sprintf(buf,"%c",*nameptr);
23415
23416 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23417
23418 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23419 cursor_x += MsgStrings[msgstr].hspace;
23420 ++nameptr;
23421 continue; //don't advance the msgptr, as the next char in it was not processed!
23422 }
23423 else doing_name_insert = false;
23424 }
23425 35500 ++msgptr;
23426
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(do_end_str)
23427 goto strendcheck;
23428
1/2
✓ Branch 0 taken 35500 times.
✗ Branch 1 not taken.
35500 if(wait_advance)
23429 return;
23430
2/2
✓ Branch 0 taken 34944 times.
✓ Branch 1 taken 556 times.
35500 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23431 {
23432
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 283 times.
556 if(MsgStrings[msgstr].nextstring)
23433 {
23434
1/2
✓ Branch 0 taken 283 times.
✗ Branch 1 not taken.
283 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23435 {
23436 msgstr=MsgStrings[msgstr].nextstring;
23437 msgpos=msgptr=0;
23438 msgfont=setmsgfont();
23439 }
23440 283 }
23441 556 }
23442 }
23443
23444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 557 times.
557 if (!do_run_menu)
23445 {
23446 557 msgclk = 72;
23447 557 msgpos = 10000;
23448 557 }
23449 557 }
23450 else
23451 62618 {
23452 breakout:
23453
23454
6/6
✓ Branch 0 taken 52044 times.
✓ Branch 1 taken 10574 times.
✓ Branch 2 taken 14660 times.
✓ Branch 3 taken 37384 times.
✓ Branch 4 taken 9854 times.
✓ Branch 5 taken 4806 times.
62618 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_bit(quest_rules,qr_ALLOWFASTMSG))))
23455 42190 return;
23456 }
23457
23458 // Start writing the string
23459
2/2
✓ Branch 0 taken 20405 times.
✓ Branch 1 taken 580 times.
21565 if(msgptr == 0)
23460 {
23461
2/2
✓ Branch 0 taken 580 times.
✓ Branch 1 taken 1101 times.
1681 while(MsgStrings[msgstr].s[msgptr]==' ')
23462 {
23463 1101 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23464
23465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
1106 if(cursor_x+tlength > (msg_w-msg_margins[right])
23466
4/6
✓ Branch 0 taken 1096 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
1101 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23467 ? 1 : strcmp(s3," ")!=0))
23468 {
23469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23470 5 ssc_tile_hei = ssc_tile_hei_buf;
23471 5 ssc_tile_hei_buf = -1;
23472 5 cursor_y += thei + MsgStrings[msgstr].vspace;
23473
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(bottom_margin_clip()) break;
23474 5 cursor_x=msg_margins[left];
23475 5 }
23476
23477 1101 cursor_x+=tlength;
23478 1101 ++msgptr;
23479 1101 ++msgpos;
23480
23481 // The "Continue From Previous" feature
23482
2/2
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 72 times.
1101 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23483 {
23484
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(MsgStrings[msgstr].nextstring)
23485 {
23486 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23487 {
23488 msgstr=MsgStrings[msgstr].nextstring;
23489 msgpos=msgptr=0;
23490 msgfont=setmsgfont();
23491 }
23492 }
23493 72 }
23494 }
23495 580 }
23496
23497 reparsesinglechar:
23498 // Continue printing the string!
23499
3/4
✓ Branch 0 taken 19822 times.
✓ Branch 1 taken 1163 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 19822 times.
40807 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
23500 {
23501
4/6
✓ Branch 0 taken 19822 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19822 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 19728 times.
19822 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23502 {
23503 19728 wrapmsgstr(s3);
23504
23505 19728 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23506
23507
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 234 times.
19982 if(cursor_x+tlength > (msg_w-msg_margins[right])
23508
6/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 19470 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 234 times.
✓ Branch 5 taken 4 times.
19728 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23509 20 ? true : strcmp(s3," ")!=0))
23510 {
23511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23512 254 ssc_tile_hei = ssc_tile_hei_buf;
23513 254 ssc_tile_hei_buf = -1;
23514 254 cursor_y += thei + MsgStrings[msgstr].vspace;
23515
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(bottom_margin_clip()) goto strendcheck;
23516 254 cursor_x=msg_margins[left];
23517 //if(space) s3[0]=0;
23518 254 }
23519
23520 19728 sfx(MsgStrings[msgstr].sfx);
23521
23522 19728 char buf[2] = {0};
23523 19728 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23524
23525 19728 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23526
23527 19728 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23528 19728 cursor_x += MsgStrings[msgstr].hspace;
23529 19728 msgpos++;
23530 19728 }
23531
1/2
✓ Branch 0 taken 19822 times.
✗ Branch 1 not taken.
19822 if(do_end_str)
23532 goto strendcheck;
23533
1/2
✓ Branch 0 taken 19822 times.
✗ Branch 1 not taken.
19822 if(wait_advance)
23534 {
23535 ++msgptr;
23536 return;
23537 }
23538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19822 times.
19822 else if(do_run_menu)
23539 {
23540 if(runMenuCursor())
23541 {
23542 do_run_menu = false;
23543 ++msgptr;
23544 goto reparsesinglechar;
23545 }
23546 }
23547
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19822 else if(doing_name_insert && *nameptr)
23548 {
23549 char s3[9] = {0};
23550
23551 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23552 {
23553 strcpy(s3, nameptr);
23554 }
23555 else
23556 {
23557 s3[0] = *nameptr;
23558 s3[1] = 0;
23559 }
23560
23561 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23562
23563 if(cursor_x+tlength > (msg_w-msg_margins[right])
23564 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23565 ? true : strcmp(s3," ")!=0))
23566 {
23567 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23568 ssc_tile_hei = ssc_tile_hei_buf;
23569 ssc_tile_hei_buf = -1;
23570 cursor_y += thei + MsgStrings[msgstr].vspace;
23571 if(bottom_margin_clip()) goto strendcheck;
23572 cursor_x=msg_margins[left];
23573 }
23574
23575 sfx(MsgStrings[msgstr].sfx);
23576
23577 char buf[2] = {0};
23578 sprintf(buf,"%c",*nameptr);
23579
23580 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23581
23582 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23583 cursor_x += MsgStrings[msgstr].hspace;
23584 ++nameptr;
23585 }
23586 else
23587 {
23588 19822 doing_name_insert = false;
23589 19822 msgptr++;
23590
23591
2/2
✓ Branch 0 taken 19330 times.
✓ Branch 1 taken 492 times.
19822 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23592 {
23593
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 59 times.
492 if(MsgStrings[msgstr].nextstring)
23594 {
23595
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23596 {
23597 msgstr=MsgStrings[msgstr].nextstring;
23598 msgpos=msgptr=0;
23599 msgfont=setmsgfont();
23600 }
23601 59 }
23602 492 }
23603
23604
2/2
✓ Branch 0 taken 2932 times.
✓ Branch 1 taken 978 times.
23732 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
23605
2/2
✓ Branch 0 taken 19775 times.
✓ Branch 1 taken 47 times.
19822 && (MsgStrings[msgstr].s[msgptr]==' ')
23606
2/2
✓ Branch 0 taken 3910 times.
✓ Branch 1 taken 15865 times.
19775 && (MsgStrings[msgstr].s[msgptr+1]==' '))
23607 {
23608
2/2
✓ Branch 0 taken 978 times.
✓ Branch 1 taken 32295 times.
33273 while(MsgStrings[msgstr].s[msgptr]==' ')
23609 {
23610 32295 msgspace = true;
23611 32295 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23612
23613
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1409 times.
33727 if(cursor_x+tlength > (msg_w-msg_margins[right])
23614
4/6
✓ Branch 0 taken 1432 times.
✓ Branch 1 taken 30863 times.
✓ Branch 2 taken 1432 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1409 times.
✗ Branch 5 not taken.
32295 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23615 23 ? true : strcmp(s3," ")!=0))
23616 {
23617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1432 times.
1432 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23618 1432 ssc_tile_hei = ssc_tile_hei_buf;
23619 1432 ssc_tile_hei_buf = -1;
23620 1432 cursor_y += thei + MsgStrings[msgstr].vspace;
23621
1/2
✓ Branch 0 taken 1432 times.
✗ Branch 1 not taken.
1432 if(bottom_margin_clip()) break;
23622 1432 cursor_x=msg_margins[left];
23623 1432 }
23624
23625 32295 cursor_x+=tlength;
23626 32295 ++msgpos;
23627 32295 ++msgptr;
23628
23629
2/2
✓ Branch 0 taken 2713 times.
✓ Branch 1 taken 29582 times.
32295 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23630 {
23631
2/2
✓ Branch 0 taken 25531 times.
✓ Branch 1 taken 4051 times.
29582 if(MsgStrings[msgstr].nextstring)
23632 {
23633
1/2
✓ Branch 0 taken 4051 times.
✗ Branch 1 not taken.
4051 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23634 {
23635 msgstr=MsgStrings[msgstr].nextstring;
23636 msgpos=msgptr=0;
23637 msgfont=setmsgfont();
23638 }
23639 4051 }
23640 29582 }
23641 }
23642 978 }
23643 }
23644 19822 }
23645 strendcheck:
23646 // Done printing the string
23647
10/14
✓ Branch 0 taken 20985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20985 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20985 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20428 times.
✓ Branch 7 taken 557 times.
✓ Branch 8 taken 19949 times.
✓ Branch 9 taken 479 times.
✓ Branch 10 taken 19949 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 19554 times.
✓ Branch 13 taken 1431 times.
20985 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
23648 {
23649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1431 times.
1431 if(!do_end_str)
23650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1431 times.
1431 while(parsemsgcode()); // Finish remaining control codes
23651
23652 // Go to next string, or make it disappear by going to string 0.
23653
5/6
✓ Branch 0 taken 1089 times.
✓ Branch 1 taken 342 times.
✓ Branch 2 taken 921 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 921 times.
1431 if(MsgStrings[msgstr].nextstring!=0 || get_bit(quest_rules,qr_MSGDISAPPEAR) || enqueued_str)
23654 {
23655 510 linkedmsgclk=do_end_str?1:51;
23656 510 }
23657
23658
2/2
✓ Branch 0 taken 1089 times.
✓ Branch 1 taken 342 times.
1431 if(MsgStrings[msgstr].nextstring==0)
23659 {
23660
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 921 times.
1089 if(!get_bit(quest_rules,qr_MSGDISAPPEAR))
23661 921 {
23662 disappear:
23663 1089 msg_active = false;
23664 1089 Hero.finishedmsg();
23665 1089 }
23666
23667
2/2
✓ Branch 0 taken 1245 times.
✓ Branch 1 taken 12 times.
1257 if(repaircharge)
23668 {
23669 // if (get_bit(quest_rules,qr_REPAIRFIX)) {
23670 // fixed_door=true;
23671 // }
23672 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
23673 12 repaircharge = 0;
23674 12 }
23675
23676
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 1 times.
1257 if(adjustmagic)
23677 {
23678
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_HALF_MAGIC))
23679 {
23680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
23681 1 game->set_magicdrainrate(1);
23682 1 }
23683 else if(game->get_magicdrainrate() > 1)
23684 {
23685 game->set_magicdrainrate(game->get_magicdrainrate()/2);
23686 }
23687 1 adjustmagic = false;
23688 1 sfx(WAV_SCALE);
23689
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23690 1 }
23691
23692
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 1 times.
1257 if(learnslash)
23693 {
23694 1 game->set_canslash(1);
23695 1 learnslash = false;
23696 1 sfx(WAV_SCALE);
23697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23698 1 }
23699 1257 }
23700 1599 }
23701 6439182 }
23702
23703 14090 int32_t message_more_y()
23704 {
23705 //Is the flag ticked, do we really want a message more y larger than 160?
23706
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14076 times.
✓ Branch 2 taken 14090 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14076 times.
✓ Branch 5 taken 14 times.
14090 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
23707 14090 msgy+=playing_field_offset;
23708 14090 return msgy;
23709 }
23710
23711 /*** Collision detection & handling ***/
23712
23713 6417041 void clear_script_one_frame_conditions()
23714 {
23715
2/2
✓ Branch 0 taken 19758569 times.
✓ Branch 1 taken 6417041 times.
26175610 for(int32_t j=0; j<guys.Count(); j++)
23716 {
23717 19758569 enemy *e = (enemy*)guys.spr(j);
23718
2/2
✓ Branch 0 taken 335895673 times.
✓ Branch 1 taken 19758569 times.
355654242 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
23719 19758569 }
23720 6417041 }
23721
23722 6416929 void check_collisions()
23723 {
23724
2/2
✓ Branch 0 taken 2621925 times.
✓ Branch 1 taken 6416929 times.
9038854 for(int32_t i=0; i<Lwpns.Count(); i++)
23725 {
23726 2621925 weapon *w = (weapon*)Lwpns.spr(i);
23727
23728
8/8
✓ Branch 0 taken 2277423 times.
✓ Branch 1 taken 344502 times.
✓ Branch 2 taken 1907203 times.
✓ Branch 3 taken 370220 times.
✓ Branch 4 taken 1885890 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 1872250 times.
2621925 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
23729 {
23730
2/2
✓ Branch 0 taken 1862126 times.
✓ Branch 1 taken 6645771 times.
8507897 for(int32_t j=0; j<guys.Count(); j++)
23731 {
23732 6645771 enemy *e = (enemy*)guys.spr(j);
23733
23734 6645771 bool didhit = e->hit(w);
23735
2/2
✓ Branch 0 taken 6519036 times.
✓ Branch 1 taken 126735 times.
6645771 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23736 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
23737 {
23738 // !(e->stunclk)
23739 126735 int32_t h = e->takehit(w);
23740
2/2
✓ Branch 0 taken 105867 times.
✓ Branch 1 taken 20868 times.
126735 if (h == -1)
23741 {
23742 20868 e->hitby[HIT_BY_LWEAPON] = i+1;
23743 20868 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
23744 20868 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
23745
2/2
✓ Branch 0 taken 1177 times.
✓ Branch 1 taken 19691 times.
20868 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
23746 1177 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
23747 20868 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
23748 20868 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
23749
23750 20868 }
23751 //we may need to handle this in special cases. -Z
23752
23753 //if h == stun or ignore
23754
23755 //if e->stun > DEFAULT_STUN -1 || !e->stun
23756 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
23757 ///! how about: if w->dead != bounce !
23758
23759 // NOT FOR PUBLIC RELEASE
23760 /*if(h==3) //Mirror shield
23761 {
23762 if (w->id==ewFireball || w->id==wRefFireball)
23763 {
23764 w->id=wRefFireball;
23765 switch(e->dir)
23766 {
23767 case up: e->angle += (PI - e->angle) * 2.0; break;
23768 case down: e->angle = -e->angle; break;
23769 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
23770 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
23771 // TODO: the following. -L.
23772 case l_up: break;
23773 case r_up: break;
23774 case l_down: break;
23775 case r_down: break;
23776 }
23777 }
23778 else
23779 {
23780 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
23781 w->dir ^= 1;
23782 if(w->dir&2)
23783 w->flip ^= 1;
23784 else
23785 w->flip ^= 2;
23786 }
23787 w->ignoreHero=false;
23788 }
23789 else*/
23790
2/2
✓ Branch 0 taken 98954 times.
✓ Branch 1 taken 27781 times.
126735 if(h)
23791 {
23792
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27781 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27781 if(e->switch_hooked && w->family_class == itype_switchhook)
23793 w->onhit(false, e, -1);
23794 27781 else w->onhit(false, e, h);
23795 27781 }
23796
23797
2/2
✓ Branch 0 taken 124426 times.
✓ Branch 1 taken 2309 times.
126735 if(h==2)
23798 {
23799 2309 break;
23800 }
23801 124426 }
23802
23803
2/2
✓ Branch 0 taken 6635647 times.
✓ Branch 1 taken 7815 times.
6643462 if(w->Dead())
23804 {
23805 7815 break;
23806 }
23807 6635647 }
23808
23809 // Item flags added in 2.55:
23810 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
23811 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
23812 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
23813 // -V
23814
6/6
✓ Branch 0 taken 1585331 times.
✓ Branch 1 taken 286919 times.
✓ Branch 2 taken 1580855 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 18036 times.
✓ Branch 5 taken 1562819 times.
1872250 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
23815 {
23816 309431 int32_t itype, pitem = w->parentitem;
23817
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 286919 times.
✓ Branch 2 taken 18036 times.
✓ Branch 3 taken 4476 times.
309431 switch(w->id)
23818 {
23819 286919 case wBrang: itype = itype_brang; break;
23820 18036 case wArrow: itype = itype_arrow; break;
23821 case wHookshot:
23822 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
23823 4476 break;
23824 }
23825
2/2
✓ Branch 0 taken 306588 times.
✓ Branch 1 taken 2843 times.
309431 if(pitem < 0) pitem = current_item_id(itype);
23826
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 304955 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
309431 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
23827 { //Swap with item
23828 for(int32_t j=0; j<items.Count(); j++)
23829 {
23830 if(items.spr(j)->hit(w))
23831 {
23832 item *theItem = ((item*)items.spr(j));
23833 bool priced = theItem->PriceIndex >-1;
23834 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23835 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23836 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23837 {
23838 if(!Hero.switchhookclk)
23839 {
23840 hooked_combopos = -1;
23841 hooked_layerbits = 0;
23842 switching_object = theItem;
23843 theItem->switch_hooked = true;
23844 w->misc = 2;
23845 w->step = 0;
23846 theItem->clk2=256;
23847 Hero.doSwitchHook(game->get_switchhookstyle());
23848 if(QMisc.miscsfx[sfxSWITCHED])
23849 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
23850 }
23851 }
23852 }
23853 }
23854 }
23855
6/6
✓ Branch 0 taken 18036 times.
✓ Branch 1 taken 291395 times.
✓ Branch 2 taken 290599 times.
✓ Branch 3 taken 272563 times.
✓ Branch 4 taken 291395 times.
✓ Branch 5 taken 272563 times.
309431 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
23856 {
23857
2/2
✓ Branch 0 taken 68650 times.
✓ Branch 1 taken 290599 times.
359249 for(int32_t j=0; j<items.Count(); j++)
23858 {
23859
2/2
✓ Branch 0 taken 64660 times.
✓ Branch 1 taken 3990 times.
68650 if(items.spr(j)->hit(w))
23860 {
23861 3990 item *theItem = ((item*)items.spr(j));
23862 3990 bool priced = theItem->PriceIndex >-1;
23863
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 3906 times.
3990 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23864
5/8
✓ Branch 0 taken 3990 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3990 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3195 times.
✓ Branch 5 taken 795 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1758 times.
5748 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23865
4/6
✓ Branch 0 taken 2553 times.
✓ Branch 1 taken 1758 times.
✓ Branch 2 taken 2553 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2553 times.
3990 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
23866 {
23867
1/2
✓ Branch 0 taken 1437 times.
✗ Branch 1 not taken.
4953 if(itemsbuf[theItem->id].collect_script)
23868 {
23869 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
23870 }
23871
23872 1437 Hero.checkitems(j);
23873 1437 }
23874 3990 }
23875 68650 }
23876 290599 }
23877
2/2
✓ Branch 0 taken 2866 times.
✓ Branch 1 taken 15966 times.
563958 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
23878 {
23879
2/2
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 15966 times.
19300 for(int32_t j=0; j<items.Count(); j++)
23880 {
23881
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 935 times.
3334 if(items.spr(j)->hit(w))
23882 {
23883 935 item *theItem = ((item*)items.spr(j));
23884 935 bool priced = theItem->PriceIndex >-1;
23885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23886
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23887
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23888 {
23889 559 int32_t pickup = theItem->pickup;
23890 559 int32_t id2 = theItem->id;
23891 559 int32_t pstr = theItem->pstring;
23892 559 int32_t pstr_flags = theItem->pickup_string_flags;
23893
23894 559 std::vector<int32_t> &ev = FFCore.eventData;
23895 559 ev.clear();
23896 559 ev.push_back(id2*10000);
23897 559 ev.push_back(pickup*10000);
23898 559 ev.push_back(pstr*10000);
23899 559 ev.push_back(pstr_flags*10000);
23900 559 ev.push_back(0);
23901 559 ev.push_back(theItem->getUID());
23902 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
23903 559 ev.push_back(w->getUID());
23904
23905 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
23906 559 bool nullify = ev[4] != 0;
23907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
23908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
23909 {
23910 559 w->onhit(false);
23911 559 }
23912
23913
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
23914 {
23915 37 w->dead=1;
23916 37 theItem->clk2=256;
23917 37 w->dragging=j;
23918 37 theItem->is_dragged = true;
23919 37 }
23920 559 }
23921 935 }
23922 3334 }
23923 15966 }
23924 309431 }
23925 1872250 }
23926 2621925 }
23927 6416929 }
23928
23929 6417041 void dragging_item()
23930 {
23931
2/2
✓ Branch 0 taken 2668377 times.
✓ Branch 1 taken 6417041 times.
9085418 for(int32_t i=0; i<Lwpns.Count(); i++)
23932 {
23933 2668377 weapon *w = (weapon*)Lwpns.spr(i);
23934
23935
4/4
✓ Branch 0 taken 2375354 times.
✓ Branch 1 taken 293023 times.
✓ Branch 2 taken 2652070 times.
✓ Branch 3 taken 16307 times.
2668377 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
23936 {
23937
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
23938 {
23939 551 item* dragItem = (item*)items.spr(w->dragging);
23940 551 dragItem->x=w->x;
23941 551 dragItem->y=w->y;
23942
23943 // Drag the Fairy enemy as well as the Fairy item
23944 551 int32_t id = dragItem->id;
23945
23946
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
23947 {
23948 movefairynew2(w->x,w->y,*dragItem);
23949 }
23950 551 }
23951 16307 }
23952 2668377 }
23953 6417041 }
23954
23955 27 int32_t more_carried_items()
23956 {
23957 27 int32_t hasmorecarries = 0;
23958
23959
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 27 times.
57 for(int32_t i=0; i<items.Count(); i++)
23960 {
23961
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27 times.
30 if(((item*)items.spr(i))->pickup & ipENEMY)
23962 {
23963 27 hasmorecarries++;
23964 27 }
23965 30 }
23966
23967 27 return hasmorecarries;
23968 }
23969
23970 // messy code to do the enemy-carrying-the-item thing
23971 6417041 void roaming_item()
23972 {
23973
4/4
✓ Branch 0 taken 12060 times.
✓ Branch 1 taken 6404981 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 12029 times.
6417041 if(!(hasitem&(4|2)) || !loaded_enemies)
23974 6405012 return;
23975
23976 // All enemies already dead upon entering a room?
23977
1/2
✓ Branch 0 taken 12029 times.
✗ Branch 1 not taken.
12029 if(guys.Count()==0)
23978 {
23979 return;
23980 }
23981
23982 // Lost track of the carrier?
23983
5/6
✓ Branch 0 taken 12029 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12028 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 12021 times.
✓ Branch 5 taken 7 times.
12029 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
23984 12028 !((enemy*)guys.spr(guycarryingitem))->itemguy)
23985 {
23986 8 guycarryingitem=-1;
23987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 for(int32_t j=0; j<guys.Count(); j++)
23988 {
23989
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 8 times.
30 if(((enemy*)guys.spr(j))->itemguy)
23990 {
23991 8 guycarryingitem=j;
23992 8 break;
23993 }
23994 22 }
23995 8 }
23996
23997
2/2
✓ Branch 0 taken 12000 times.
✓ Branch 1 taken 29 times.
12029 if(hasitem&4)
23998 {
23999 29 guycarryingitem = -1;
24000
24001
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 29 times.
248 for(int32_t i=0; i<guys.Count(); i++)
24002 {
24003
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 29 times.
219 if(((enemy*)guys.spr(i))->itemguy)
24004 {
24005 29 guycarryingitem = i;
24006 29 }
24007 219 }
24008
24009
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(guycarryingitem == -1) //This happens when "default enemies" such as
24010 {
24011 return; //eSHOOTFBALL are alive but enemies from the list
24012 } //are not. Defer to HeroClass::checkspecial().
24013
24014 29 int32_t Item=tmpscr->item;
24015
24016 29 hasitem &= ~4;
24017
24018
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
29 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
24019 {
24020 55 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
24021
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 26 times.
29 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
24022 );
24023 29 hasitem |= 2;
24024 29 }
24025 else
24026 {
24027 return;
24028 }
24029 29 }
24030
24031
2/2
✓ Branch 0 taken 12784 times.
✓ Branch 1 taken 12029 times.
24813 for(int32_t i=0; i<items.Count(); i++)
24032 {
24033
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 12029 times.
12784 if(((item*)items.spr(i))->pickup&ipENEMY)
24034 {
24035
2/2
✓ Branch 0 taken 4808 times.
✓ Branch 1 taken 7221 times.
12029 if(get_bit(quest_rules,qr_HIDECARRIEDITEMS))
24036 {
24037 7221 items.spr(i)->x = -128; // Awfully inelegant, innit?
24038 7221 items.spr(i)->y = -128;
24039 7221 }
24040
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
24041 {
24042
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
24043 {
24044 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
24045 {
24046 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hxsz/2)-8;
24047 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hysz/2)-10;
24048 }
24049 else
24050 {
24051 if(guys.spr(guycarryingitem)->extend >= 3)
24052 {
24053 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
24054 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
24055 }
24056 else
24057 {
24058 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24059 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24060 }
24061 }
24062 items.spr(i)->z = guys.spr(guycarryingitem)->z;
24063 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24064 }
24065 else
24066 {
24067 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
24068 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
24069 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
24070 }
24071 4808 }
24072 12029 }
24073 12784 }
24074 6417041 }
24075
24076 bool enemy::IsBigAnim()
24077 {
24078 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
24079 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
24080 || anim == a4FRM8DIRB);
24081 }
24082
24083 const char *old_guy_string[OLDMAXGUYS] =
24084 {
24085 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
24086 // 020
24087 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
24088 // 025
24089 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
24090 // 030
24091 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
24092 // 035
24093 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
24094 // 040
24095 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
24096 // 045
24097 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
24098 // 050
24099 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
24100 // 055
24101 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
24102 // 060
24103 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
24104 // 065
24105 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
24106 // 070
24107 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
24108 // 075
24109 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
24110 // 080
24111 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
24112 // 085
24113 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
24114 // 090
24115 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
24116 // 095
24117 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
24118 // 100
24119 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
24120 // 105
24121 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
24122 // 110
24123 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
24124 // 115
24125 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
24126 // 120
24127 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
24128 // 125
24129 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
24130 // 130
24131 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
24132 // 135
24133 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
24134 // 140
24135 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
24136 // 145
24137 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
24138 // 150
24139 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
24140 // 155
24141 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
24142 // 160
24143 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
24144 // 165
24145 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
24146 // 170
24147 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
24148 // 175
24149 "Grappler Bug (HP) ", "Grappler Bug (MP) "
24150 };
24151